[material-ui][Slider] Set CSS writing-mode and update vertical slider docs#44537
[material-ui][Slider] Set CSS writing-mode and update vertical slider docs#44537mj12albert merged 22 commits intomui:masterfrom
writing-mode and update vertical slider docs#44537Conversation
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
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 |
DiegoAndai
left a comment
There was a problem hiding this comment.
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.
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.
|
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 |
DiegoAndai
left a comment
There was a problem hiding this comment.
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-modeproperty in the<input type="range">element's styles to ensureorientationis exposed correctly in the accessibility treefireEvent.keyDown, most of the existing tests usefireEvent.changewhich did not catch some incorrect behaviorskeydownhandler instead of splitting them across thekeydownandchangehandlers. This takes care of a side effect of using CSSwriting-modeto 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