-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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-ui][Slider] Set CSS writing-mode
and update vertical slider docs
#44537
Conversation
writing-mode
and update vertical slider docs
4b5574e
to
5c830c3
Compare
Netlify deploy preview@material-ui/core: parsed: +0.12% , gzip: +0.14% Bundle size reportDetails of bundle changes (Toolpad) |
e3164ed
to
0c864c7
Compare
7803c4b
to
64ba470
Compare
Fixed the rest of the comments ~ |
64ba470
to
9fa734e
Compare
9fa734e
to
9dc7bf7
Compare
@mj12albert arrow keys are still reversed. Is that expected? e.g. in https://deploy-preview-44537--material-ui.netlify.app/material-ui/react-slider/#vertical-sliders |
🥲 nope – let me fix this |
Fix for reversed arrow keys is still pending
ecd4102
to
c865329
Compare
0304fad
to
cc32deb
Compare
Yes ~ sandbox here just to be sure: https://codesandbox.io/p/sandbox/material-ui-slider-writing-mode-jkw4kn?file=%2Fsrc%2FApp.js%3A1%2C1
Yes ~ thats correct, I've also removed the constants now @DiegoAndai |
Clarification: I may not have been specific enough here (though this is just to document the fact and doesn't affect the PR now) - with |
@mj12albert I'm confused, you shared two demos:
In the first one, both sliders increase with the Up Arrow But both have |
This first one is with the fixes in this PR!
This second one is just a fork of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This first one is with the fixes in this PR!
This second one is just a fork of the VerticalAccessibleSlider demo on master
I see, it makes sense now 😅.
From the description:
Handle all keypresses in the keydown handler instead of splitting them across the keydown and change handlers
I see that in this PR we're handling all keys in the keydown handler, but I don't see the removal from the change handlers. Am I missing something?
@aarongarciah If we released this in a minor version, we would have to add an explanation to the changelog. The breaking change would be that for the users who didn't follow our recommendation of preventing default. For them, the left/right arrow keys would be swapped when updating.
I consider it a 'softer' breaking change as it will only affect people who didn't follow the recommendation. But, there will probably be some users that notice the change and are not happy with it, so if we wanted to play it extra safe, we could hold until v7. Your call.
|
||
{{"demo": "VerticalAccessibleSlider.js"}} | ||
For Chrome 124 and newer, the slider includes the CSS [`writing-mode`](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_writing_modes/Vertical_controls#range_sliders_meters_and_progress_bars) property that fixes this bug. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users don't have to add this themselves, right? I would remove/rewrite this, otherwise I think people might think they need to provide it themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
I think we can ship this in a minor. |
f463c0f |
I didn't explain my question well enough 😅 here it goes again:
|
@DiegoAndai In the keydown handler, material-ui/packages/mui-material/src/Slider/useSlider.ts Lines 357 to 371 in c279aea
So it wouldn't get handled twice (I think lots of tests would have broke if it did) |
@mj12albert and what about:
I can't seem to find where it was handled before this PR |
@DiegoAndai in the keydown handler prior to this PR, some keys (e.g. So those keys will continue to trigger keyup > keypress > change, and the change event will cause the value to be changed by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, nice work @mj12albert 😊
Three things:
- This requires a minor bump on the next release
- In the release notes, let's add a heads up about it and link to this PR
- In this PR's description PR, let's add an explanation of what can users expect with the change, for users that end up here from the release notes
@mj12albert I provided more detail in the description, feel free to correct anything I might've missed. |
Thanks, looks good ~ |
User-facing changes
Note: This only affects vertical sliders.
Previously, we recommended preventing the default behavior on the left and right arrow keys when using vertical sliders as there were some browsers' inconsistencies resulting in the keys being reversed. When preventing the default behavior, the left and right arrows didn't change the slider's value, and only the up and down arrows did.
What this PR changes
writing-mode
property in the<input type="range">
element's styles to ensureorientation
is exposed correctly in the accessibility treefireEvent.keyDown
, most of the existing tests usefireEvent.change
which did not catch some incorrect behaviorskeydown
handler instead of splitting them across thekeydown
andchange
handlers. This takes care of a side effect of using CSSwriting-mode
to fix the a11y issue – it causes native range inputs to render top-to-bottom in LTR (reference), and bottom-to-top in RTL, which is counter-intuitive 😆 (but its the spec).Closes #44237