Skip to content

Commit 1e58328

Browse files
authored
ColorArea: remove aria-roledescription on iOS/Android (#2547)
* ColorArea: remove aria-roledescription on iOS/Android To better reflect behavior of slider inputs with mobile screen readers on iOS and Android, each input should be labeled by its individual channel name and we should remove aria-roledescription so the input is identified simply as a slider control. * ColorArea: change aria-valuetext for iOS/Android On iOS/Android, the aria-valuetext for each slider within the ColorArea control should just be the value for that channel, and need not include the value for the second channel. The value for all three channels is included as the title attribute. * ColorArea: include channel name in aria-valuetext for iOS/Android
1 parent 09097c5 commit 1e58328

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/@react-aria/color/src/useColorArea.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import {AriaColorAreaProps} from '@react-types/color';
1414
import {ColorAreaState} from '@react-stately/color';
15-
import {focusWithoutScrolling, mergeProps, useGlobalListeners, useLabels} from '@react-aria/utils';
15+
import {focusWithoutScrolling, isAndroid, isIOS, mergeProps, useGlobalListeners, useLabels} from '@react-aria/utils';
1616
// @ts-ignore
1717
import intlMessages from '../intl/*.json';
1818
import {MessageDictionary} from '@internationalized/message';
@@ -272,15 +272,16 @@ export function useColorArea(props: AriaColorAreaProps, state: ColorAreaState, i
272272
})
273273
}, keyboardProps, movePropsThumb);
274274

275+
let isMobile = isIOS() || isAndroid();
275276

276277
let xInputLabellingProps = useLabels({
277278
...props,
278-
'aria-label': `${state.value.getChannelName(xChannel, locale)} / ${state.value.getChannelName(yChannel, locale)}`
279+
'aria-label': isMobile ? state.value.getChannelName(xChannel, locale) : `${state.value.getChannelName(xChannel, locale)} / ${state.value.getChannelName(yChannel, locale)}`
279280
});
280281

281282
let yInputLabellingProps = useLabels({
282283
...props,
283-
'aria-label': `${state.value.getChannelName(xChannel, locale)} / ${state.value.getChannelName(yChannel, locale)}`
284+
'aria-label': isMobile ? state.value.getChannelName(yChannel, locale) : `${state.value.getChannelName(xChannel, locale)} / ${state.value.getChannelName(yChannel, locale)}`
284285
});
285286

286287
let colorAriaLabellingProps = useLabels(props);
@@ -291,7 +292,7 @@ export function useColorArea(props: AriaColorAreaProps, state: ColorAreaState, i
291292
`${state.value.getChannelName('blue', locale)}: ${state.value.formatChannelValue('blue', locale)}`
292293
].join(', ');
293294

294-
let ariaRoleDescription = messages.getStringForLocale('twoDimensionalSlider', locale);
295+
let ariaRoleDescription = isMobile ? null : messages.getStringForLocale('twoDimensionalSlider', locale);
295296

296297
let {visuallyHiddenProps} = useVisuallyHidden({style: {
297298
opacity: '0.0001',
@@ -318,10 +319,10 @@ export function useColorArea(props: AriaColorAreaProps, state: ColorAreaState, i
318319
max: state.value.getChannelRange(xChannel).maxValue,
319320
step: xChannelStep,
320321
'aria-roledescription': ariaRoleDescription,
321-
'aria-valuetext': [
322+
'aria-valuetext': (isMobile ? `${state.value.getChannelName(xChannel, locale)}: ${state.value.formatChannelValue(xChannel, locale)}` : [
322323
`${state.value.getChannelName(xChannel, locale)}: ${state.value.formatChannelValue(xChannel, locale)}`,
323324
`${state.value.getChannelName(yChannel, locale)}: ${state.value.formatChannelValue(yChannel, locale)}`
324-
].join(', '),
325+
].join(', ')),
325326
title: getValueTitle(),
326327
disabled: isDisabled,
327328
value: state.value.getChannelValue(xChannel),
@@ -338,10 +339,10 @@ export function useColorArea(props: AriaColorAreaProps, state: ColorAreaState, i
338339
max: state.value.getChannelRange(yChannel).maxValue,
339340
step: yChannelStep,
340341
'aria-roledescription': ariaRoleDescription,
341-
'aria-valuetext': [
342+
'aria-valuetext': (isMobile ? `${state.value.getChannelName(yChannel, locale)}: ${state.value.formatChannelValue(yChannel, locale)}` : [
342343
`${state.value.getChannelName(yChannel, locale)}: ${state.value.formatChannelValue(yChannel, locale)}`,
343344
`${state.value.getChannelName(xChannel, locale)}: ${state.value.formatChannelValue(xChannel, locale)}`
344-
].join(', '),
345+
].join(', ')),
345346
'aria-orientation': 'vertical',
346347
title: getValueTitle(),
347348
disabled: isDisabled,

0 commit comments

Comments
 (0)