-
-
Notifications
You must be signed in to change notification settings - Fork 105
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 accessibility #320
Slider accessibility #320
Conversation
Improve slider support to assistive technologies (e.g.: screen readers): - Add "pause" options to slider initialization: - pauseOnFocus: Slider should pause when receive keyboard focus; - pauseOnHover: Slider should pause when hovered by mouse; - New "indicatorLabelFunc": Must generate ARIA labels for indicators; - New eventPause prop: is true if slider is paused by focus/hover event; - Slider must receive id if does not have one; - Sliders are able to receive focus by code; - Non-current slides are also hidden in CSS (also from screen readers); - Add button to indicators: - Update CSS; - Update event handlers. - Indicator click should focus current slide.
Implement slider tests: - Add HTML test implementation for Slider; - Add jasmine test spec for Slider (js + fixture).
- Add description for new initialization options; - Add description for new instance properties; - Add alternative text for images (updating code samples); - Update Slider init code sample to include indicatorLabelFunc example.
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.
sorry takes too long, got busy at work 😅
well we already depended with the cash library, so we might as well as use it instead of rewriting it with native JS.
also some formatting issues. I recommend you to use Prettier to format the code 😉
- Add missing indicatorLabelFunc prop to Slider#options; - Replace double quotes string by single quotes; - Replace vanilla JS calls by jQuery functions.
- Replace double quotes string by single quotes; - Replace vanilla JS calls by jQuery functions.
Mark "indicatorLabelFunc" as optional in docs description and code samples.
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.
Proposed changes
Enhanced accessibility performance of Materialize's Slider component by adding proper ARIA attributes and better support to keyboard navigation.
Following W3C's accessible carousel example, some new accessibility features have been implemented:
In the advent of the implementation of those new features, some "side features" had to be implemented:
¹ It is important to take notice that calling
slider.pause()
by code has precedence over pauses caused by events. Thus, the slider will not resume when mouse leaves the slider or when focus is lost.NB: There are other aspects of an "accessible slider" covered by W3C example which were not implemented here due to lack of escope (e.g.: Our current implementation does not provides a play/pause button per spec.).
PS.: Since this component did not have any test implementation, a new complete set of test files have also been implemented 😄.
Screenshots (if appropriate) or codepen:
Video
Slider.Accessibility.sample.mp4
Screen capture video of Firefox browser displaying a sample slider. It is paused on mouse hover and on focus. It also sets focus to its respective slide when a indicator is selected².
² Focus style has been set for demo purposes.
Image
Slider accessibility properties.
Types of changes
Checklist: