Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[joy-ui][AccordionGroup] Fix console warning when using custom color #38950

Merged
merged 6 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/mui-joy/src/AccordionGroup/AccordionGroup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,11 @@ describe('<AccordionGroup />', () => {

describeJoyColorInversion(<AccordionGroup />, { muiName: 'JoyAccordionGroup', classes });
});

it('should not warn when using custom color', () => {
expect(() => {
// @ts-expect-error as `custom` color is not part of the type system
Copy link
Contributor Author

@sai6855 sai6855 Sep 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using @ts-expect-error, we can follow this guide (https://mui.com/joy-ui/customization/theme-colors/#adding-new-palettes) and fix ts issue, but i felt it will become bit over board for the test

render(<AccordionGroup color="custom" />);
}).not.toErrorDev();
});
});
5 changes: 4 additions & 1 deletion packages/mui-joy/src/AccordionGroup/AccordionGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ AccordionGroup.propTypes /* remove-proptypes */ = {
* The color of the component. It supports those theme colors that make sense for this component.
* @default 'neutral'
*/
color: PropTypes.oneOf(['danger', 'neutral', 'primary', 'success', 'warning']),
color: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['danger', 'neutral', 'primary', 'success', 'warning']),
PropTypes.string,
]),
/**
* The component used for the root node.
* Either a string to use a HTML element or a component.
Expand Down