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

[Slider][Badge] Fix classes prop not working #24034

Merged
merged 11 commits into from
Dec 18, 2020

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Dec 17, 2020

Fixes #24033

@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Dec 17, 2020
@mui-pr-bot
Copy link

mui-pr-bot commented Dec 17, 2020

@material-ui/core: parsed: +0.08% , gzip: +0.05%

Details of bundle changes

Generated by 🚫 dangerJS against 78c86e8

@mnajdova
Copy link
Member Author

mnajdova commented Dec 17, 2020

One issue I see is with the pseudo selectors: disabled, active etc. We cannot currently override those via classes.disabled or classes.active

Another issue I found is, I am considering the vertical as a pseudo selector as well, I believe we should change the logic and check for the prop there, instead of applying the overrides under subselector, as classes.vertical will not work...

So generally, is it good rule of thumb, to always use the props and apply some styles conditionally, unless the props are related to some global selector, like disabled, active etc.. cc @oliviertassinari

Edit:

I meant should we refactor this kinds of styles - https://github.com/mui-org/material-ui/pull/24034/files#diff-4bc6eb4ab21a45337e0ab1a81a8bda390122ca0d7b040b3f2a3d7ca0f24232d8R229-R232

-'&.MuiSlider-vertical' {}
+...(props.styleProps.vertical && {}),

@mnajdova
Copy link
Member Author

We should also probably add more tests, that the classes prop will be working as expected (currently we are testing only the utility classes as far as I could see

@oliviertassinari
Copy link
Member

oliviertassinari commented Dec 17, 2020

One issue I see is with the pseudo selectors: disabled, active etc. We cannot currently override those via classes.disabled or classes.active

@mnajdova What do you mean by override? Do you mean "we can't provide a custom class name" which would be a bug or "we can't override the CSS" which sounds expected.

I am considering the vertical as a pseudo selector as well,

It could have been better in the past to use .Mui-active for the active labels, it's what would have been more consistent. For the vertical slider, I think that we have historically increased the specificity for simplicity when writing the CSS, to avoid an exposition of style rules. But in any case, I think that as long as v5 doesn't increase the specificity, it's not breaking.

@mnajdova
Copy link
Member Author

@mnajdova What do you mean by override? Do you mean "we can't provide a custom class name" which would be a bug or "we can't override the CSS" which sounds expected.

Will fix the component to accept custom classes.disabled classname, for the overrides my assumption was wrong, of course the specificity is bigger and it cannot be overridden if it is not again with the same specificity.

Let me then refactor the vertical slider with these changes and we can test that as well in the end

@@ -747,9 +757,8 @@ const SliderUnstyled = React.forwardRef(function SliderUnstyled(props, ref) {
onMouseLeave={handleMouseLeave}
{...thumbProps}
className={clsx(utilityClasses.thumb, thumbProps.className, {
[sliderUnstyledClasses['active']]: active === index,
[sliderUnstyledClasses['disabled']]: disabled,
Copy link
Member Author

@mnajdova mnajdova Dec 17, 2020

Choose a reason for hiding this comment

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

It is already applied in the useSliderClasses

@mnajdova
Copy link
Member Author

@oliviertassinari should we also merge this one mnajdova#20 for removing the usage of invisible classes selectors in the Badge component?

@oliviertassinari
Copy link
Member

should we also merge this one mnajdova#20 for removing the usage of invisible classes selectors in the Badge component?

No preferences

@@ -40,7 +40,6 @@ const BadgeUnstyled = React.forwardRef(function BadgeUnstyled(props, ref) {
vertical: 'top',
horizontal: 'right',
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a lint rule to disable eslint-disable for some rules? 😁

Copy link
Member Author

Choose a reason for hiding this comment

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

Hahahahha, nah it's just me :D

@mnajdova
Copy link
Member Author

mnajdova commented Dec 17, 2020

should we also merge this one mnajdova#20 for removing the usage of invisible classes selectors in the Badge component?

No preferences

I'll merge it to have one PR complete all the necessary changes I found at this moment. If we receive another problem, we can revisit later again

EDIT: WON'T MERGE

Reverted the changes, as this is how it was implemented in v4.

@oliviertassinari oliviertassinari added component: badge This is the name of the generic UI component, not the React module! component: slider This is the name of the generic UI component, not the React module! labels Dec 17, 2020
@oliviertassinari oliviertassinari changed the title [Slider, Badge] Fix classes prop not working [Slider][Badge] Fix classes prop not working Dec 17, 2020
@mnajdova mnajdova merged commit 5d31a60 into mui:next Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: badge This is the name of the generic UI component, not the React module! component: slider This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Slider] Can not use prop classes
4 participants