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

[Material You] Update Button test & add active class name #35497

Merged
merged 3 commits into from
Dec 23, 2022

Conversation

mnajdova
Copy link
Member

I started the PR with the need to fix the active state for the Button, and then realized that in the test we were testing the @mui/material/Button, instead of @mui/material-next/Button, so I re-write the test and added some necessary features to the describeConformance test suit, mainly around supporting different createTheme feature.

@@ -919,6 +922,29 @@ function describeConformance(
minimalElement: React.ReactElement,
getOptions: () => InputConformanceOptions,
) {
let originalMatchmedia: typeof window.matchMedia;
Copy link
Member Author

Choose a reason for hiding this comment

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

Need to mock the matchMedia for the CssVarsProvider to work.

expect(button).not.to.have.class(classes.colorPrimary);
});

['filled', 'filledTonal', 'outlined', 'elevated'].forEach((variant) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Just simplified the tests, and changed the classes we want to test out. For example in Material You, we don't have a combination of classes with multiple props, like textPrimary, outlinedPrimary etc. This is why we need less tests.

@mui-bot
Copy link

mui-bot commented Dec 15, 2022

Messages
📖 Netlify deploy preview: https://deploy-preview-35497--material-ui.netlify.app/

Details of bundle changes

Generated by 🚫 dangerJS against a651b4f

@@ -348,7 +350,7 @@ export const ButtonRoot = styled('button', {
backgroundColor: hoveredContainerColor[ownerState.variant ?? 'text'],
boxShadow: hoveredContainerElevation[ownerState.variant ?? 'text'],
},
'&:active': {
[`&.${buttonClasses.active}`]: {
Copy link
Member Author

Choose a reason for hiding this comment

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

cc @siriwatknp we may need this change in Joy UI too. For e.g. see #35410 for bugs that could arise without using it.

Copy link
Member

Choose a reason for hiding this comment

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

Got it.

@mnajdova mnajdova marked this pull request as ready for review December 16, 2022 11:30
@@ -416,6 +418,7 @@ const Button = React.forwardRef(function Button<
centerRipple = false,
children,
className,
classes: classesProp,
Copy link
Member

@siriwatknp siriwatknp Dec 22, 2022

Choose a reason for hiding this comment

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

Out of curiosity, does the Material You component still accept classes prop?

In Joy UI, the classes prop is removed because it can be done with slotProps.className.

Copy link
Member Author

@mnajdova mnajdova Dec 22, 2022

Choose a reason for hiding this comment

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

I left the API to be close with the current Material UI components. There are other adventages for the classes prop, like allowing state classes to be passed, like disabled, active etc. Also, we come to the understanding that it's a nice shortcut, as we've seen when working with the MUI Base components (that do not support this API).

Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

👍

@mnajdova mnajdova merged commit c166d8b into mui:master Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants