From d2e468b30b6d756fd713305d0ac33f2ef739733f Mon Sep 17 00:00:00 2001 From: Devon Govett Date: Thu, 17 Dec 2020 18:46:19 -0500 Subject: [PATCH 1/2] Work around iOS VoiceOver labeling issue with Slider --- packages/@react-aria/slider/src/useSlider.ts | 7 +++++-- packages/@react-aria/slider/test/useSlider.test.js | 2 +- packages/@react-spectrum/slider/test/RangeSlider.test.tsx | 4 +++- packages/@react-spectrum/slider/test/Slider.test.tsx | 4 +++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/@react-aria/slider/src/useSlider.ts b/packages/@react-aria/slider/src/useSlider.ts index 162a7671941..f67c598672a 100644 --- a/packages/@react-aria/slider/src/useSlider.ts +++ b/packages/@react-aria/slider/src/useSlider.ts @@ -153,8 +153,11 @@ export function useSlider( }; if (labelProps.htmlFor) { - // Override the `for` attribute to point to the first thumb instead of the group element. - labelProps.htmlFor = labelProps.htmlFor ? getSliderThumbId(state, 0) : undefined, + // Ideally the `for` attribute should point to the first thumb, but VoiceOver on iOS + // causes this to override the `aria-labelledby` on the thumb. This causes the first + // thumb to only be announced as the slider label rather than its individual name as well. + // See https://bugs.webkit.org/show_bug.cgi?id=172464. + delete labelProps.htmlFor; labelProps.onClick = () => { // Safari does not focus elements when clicking on an associated