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

[SliderUnstyled] Fix dragging on disabled sliders #31882

Merged
merged 1 commit into from
Mar 21, 2022

Conversation

mnajdova
Copy link
Member

Fixes #31851

@mnajdova mnajdova requested a review from a team March 18, 2022 14:14
@mui-bot
Copy link

mui-bot commented Mar 18, 2022

Details of bundle changes

Generated by 🚫 dangerJS against e97f8f7

@danilo-leal danilo-leal added component: slider This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base labels Mar 18, 2022
Copy link
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

👍 LGTM

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

From my perspective, this is the whole fix:

[`&.${sliderClasses.disabled}`]: {
pointerEvents: 'none',
cursor: 'default',
color: theme.palette.grey[400],
},

updating the demo. The cursor/color is still wrong on this PR, proof: https://codesandbox.io/s/unstyledslider-material-demo-forked-sq5hq6

@mnajdova
Copy link
Member Author

mnajdova commented Mar 21, 2022

From my perspective, this is the whole fix:

 [`&.${sliderClasses.disabled}`]: { 
   pointerEvents: 'none', 
   cursor: 'default', 
   color: theme.palette.grey[400], 
 }, 

updating the demo.

I will add this in addition, but I still think we need to disable the interaction on the component itself. We already support the prop, so why not handle it in the unstyled component? We partially handle some of the interaction based on the disabled prop, but not all, which can be confusing.


Edited: @michaldudak could you update the unstyled demos with the codesnippet above in #31850 to avoid conflicts?

@michaldudak
Copy link
Member

could you update the unstyled demos with the codesnippet above in #31850 to avoid conflicts?

Sure! As the interaction is blocked in the event handlers, we don't need pointer-events: none, do we?

@mnajdova
Copy link
Member Author

Sure! As the interaction is blocked in the event handlers, we don't need pointer-events: none, do we?

Good point, yes, we shouldn't need it.

@michaldudak
Copy link
Member

Actually, it prevents the hover styles from kicking in, so I decided to leave it after all.

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.

One of these cases where tests take 5x more effort than the implementation :)
Good job!

@hbjORbj hbjORbj merged commit 4aff57b into mui:master Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: slider This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SliderUnstyled] disabled prop does not disable interaction with the Slider
7 participants