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

feat(slider): Use input with type="range" to back slider component. This ensures that sliders can be adjusted with touch-based assistive technologies, as the current ARIA spec for sliders is not compatible with e.g. TalkBack/Android. #6643

Merged
merged 1 commit into from
Nov 24, 2020

Conversation

copybara-service[bot]
Copy link
Contributor

feat(slider): Use input with type="range" to back slider component. This ensures that sliders can be adjusted with touch-based assistive technologies, as the current ARIA spec for sliders is not compatible with e.g. TalkBack/Android.

This PR does the following:

  • When input is focused, adds focused style to slider thumb, and for discrete sliders, shows value indicator
  • On input change event (e.g. key [LEFT/RIGHT/UP/DOWN] events on input that adjust value), change internal slider value
  • On internal slider value change (e.g. via pointer events), sync input value attribute and property
  • On thumb drag start, focus input (such that users can use a mix of pointer and key events)

BREAKING CHANGE: Slider is now backed by an input of type="range". Additionally, adapter methods (focusInput, isInputFocused, registerInputEventHandler, deregisterInputEventHandler) were added.

@google-cla google-cla bot added the cla: yes label Nov 23, 2020
@copybara-service copybara-service bot force-pushed the cl/343332482 branch 9 times, most recently from 79d17ff to 07db3f7 Compare November 24, 2020 20:55
…his ensures that sliders can be adjusted with touch-based assistive technologies, as the current ARIA spec for sliders is not compatible with e.g. TalkBack/Android.

This PR does the following:
- When input is focused, adds focused style to slider thumb, and for discrete sliders, shows value indicator
- On input `change` event (e.g. key [LEFT/RIGHT/UP/DOWN] events on input that adjust value), change internal slider value
- On internal slider value change (e.g. via pointer events), sync input value attribute and property
- On thumb drag start, focus input (such that users can use a mix of pointer and key events)

BREAKING CHANGE: Slider is now backed by an input of type="range". Additionally, adapter methods (focusInput, isInputFocused, registerInputEventHandler, deregisterInputEventHandler) were added.

PiperOrigin-RevId: 344116908
@copybara-service copybara-service bot merged commit 9083b7d into master Nov 24, 2020
@copybara-service copybara-service bot deleted the cl/343332482 branch November 24, 2020 21:04
@patrickhlauke
Copy link

@joyzhong can I ask a naive question? i've been testing https://material-components.github.io/material-components-web-catalog/#/component/slider on iOS with VoiceOver, and the sliders work fine (being able to swipe up/down to change the value), but when I look at the DOM for those sliders, I don't see any actual <input type="range"> elements. are they hidden somehow (something perhaps with shadow DOM that is eluding me? admittedly, I'm not overly familiar with how this framework goes about things)

@joyzhong
Copy link
Contributor

joyzhong commented Jul 8, 2021

Hey, apologies for the delayed response! The component catalog is out-of-date and unmaintained currently. You can see a demo of the current slider implementation here instead: https://codepen.io/joyzhong/pen/rNmarao

Since it's backed by a native range input, you can use the volume keys to adjust the slider value when using VO/iOS or TalkBack/Android.

@patrickhlauke
Copy link

@joyzhong thanks, i since managed to work out how https://material-components.github.io/material-components-web-catalog/#/component/slider also manages to work in iOS/VO without the <input type="range"> ... turns out VO implements the AOM faked/fallback keyboard events https://github.com/WICG/aom/blob/gh-pages/explainer.md#user-action-events-from-assistive-technology which mean the swipe up/down actually generate synthetic key events, which make the outdated catalogue slider still work (but obviously not Talkback). mystery solved. w3c/aria-practices#8 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants