-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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] Add getAriaLabel prop #17240
Conversation
Details of bundle changes.Comparing: f55f3a4...76b3746
|
renamed the commit to make the new PR name |
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 looks great! Should we update http://material-ui.com/components/slider/#accessibility too? Like
diff --git a/docs/src/pages/components/slider/slider.md b/docs/src/pages/components/slider/slider.md
index c85ada73f..bc9d5a4a0 100644
--- a/docs/src/pages/components/slider/slider.md
+++ b/docs/src/pages/components/slider/slider.md
@@ -53,7 +53,7 @@ Continuous sliders allow users to select a value along a subjective range.
The component handles most of the work necessary to make it accessible.
However, you need to make sure that:
-- The slider, as a whole, has a label (`aria-label` or `aria-labelledby` prop).
-- Each thumb has a user-friendly name for its current value.
+- Each thumb has a user-friendly label (`aria-label`, `aria-labelledby` or `getAriaLabel` prop).
+- Each thumb has a user-friendly text for its current value.
This is not required if the value matches the semantics of the label.
You can change the name with the `getAriaValueText` or `aria-valuetext` prop.
Don't worry about the commit name, we erase it when we merge. |
While we're here, should we |
I think that we should keep it because we have a non default behavior, the aria prop is not applied on the root element. |
The API docs don't mention that, they simply document the standard aria props. If that implementation detail is important, it could be mentioned in the accessibility section. Speaking of which, what does "This is not required if the value matches the semantics of the label." mean? |
I updated the messages as well as slider.md's accessibility section (didn't realize that existed, thanks for the heads up) |
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 is a great step towards better a11y of range sliders.
Could you add a test with a range slider and getAriaLAbel
? I think you can use getByLabelText()
and check that it has the slider role. That should cover most a11y concerns of this feature.
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.
Just a minor nitpick about test failure messages.
Awesome |
getAriaLabel doesn't work.
but it seems getAriaLabel isn't even being called |
@007sya Please open a new issue and fill out the template. It's hard to to resolve in an already merged PR. |
Fixes #17231
I followed the pattern set by
getAriaValueText
. I noticed its documentation wasn't quite right (missed@returns {string}
so I added that to both functions.The only test I added is for the console warning, which matches the test coverage of
getAriaValueText
.Also, should
aria-labelledby
have an equivalentgetAriaLabelledBy
?