Skip to content

Commit 3779ccf

Browse files
authored
Merge pull request Expensify#79149 from rushatgabhane/a11y/keyboard-inputs
2 parents 9fd2604 + 38911b3 commit 3779ccf

22 files changed

Lines changed: 44 additions & 24 deletions

File tree

src/components/AmountTextInput.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ function AmountTextInput({
8383
submitBehavior="submit"
8484
selection={selection}
8585
onSelectionChange={onSelectionChange}
86-
role={CONST.ROLE.PRESENTATION}
8786
onKeyPress={onKeyPress as (event: TextInputKeyPressEvent) => void}
8887
touchableInputWrapperStyle={touchableInputWrapperStyle}
8988
// On iPad, even if the soft keyboard is hidden, the keyboard suggestion is still shown.

src/components/Banner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function Banner({
131131
<PressableWithFeedback
132132
onPress={onClose}
133133
role={CONST.ROLE.BUTTON}
134-
accessibilityLabel={translate('common.close')}
134+
accessibilityLabel={text ? `${translate('common.close')}, ${text}` : translate('common.close')}
135135
>
136136
<Icon
137137
src={expensifyIcons.Close}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import CONST from '@src/CONST';
22
import type {GetButtonRole} from './types';
33

4-
const getButtonRole: GetButtonRole = (isNested) => (isNested ? CONST.ROLE.PRESENTATION : CONST.ROLE.BUTTON);
4+
const getButtonRole: GetButtonRole = () => CONST.ROLE.BUTTON;
55

66
// eslint-disable-next-line import/prefer-default-export
77
export {getButtonRole};

src/components/DatePicker/CalendarPicker/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ function CalendarPicker({
194194
disabled={years.length <= 1}
195195
testID="currentYearButton"
196196
accessibilityLabel={translate('common.currentYear')}
197+
role={CONST.ROLE.BUTTON}
197198
>
198199
<Text
199200
style={themeStyles.sidebarLinkTextBold}
@@ -219,6 +220,7 @@ function CalendarPicker({
219220
onPress={moveToPrevMonth}
220221
hoverDimmingValue={1}
221222
accessibilityLabel={translate('common.previous')}
223+
role={CONST.ROLE.BUTTON}
222224
>
223225
<ArrowIcon
224226
disabled={!hasAvailableDatesPrevMonth}
@@ -232,6 +234,7 @@ function CalendarPicker({
232234
onPress={moveToNextMonth}
233235
hoverDimmingValue={1}
234236
accessibilityLabel={translate('common.next')}
237+
role={CONST.ROLE.BUTTON}
235238
>
236239
<ArrowIcon disabled={!hasAvailableDatesNextMonth} />
237240
</PressableWithFeedback>
@@ -279,6 +282,7 @@ function CalendarPicker({
279282
tabIndex={day ? 0 : -1}
280283
accessible={!!day}
281284
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
285+
role={CONST.ROLE.BUTTON}
282286
>
283287
{({hovered, pressed}) => (
284288
<DayComponent

src/components/MenuItem.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ type MenuItemBaseProps = ForwardedFSClassProps &
211211
/** Text to display for the item */
212212
title?: string;
213213

214+
/** Accessibility label for the menu item */
215+
accessibilityLabel?: string;
216+
214217
/** Component to display as the title */
215218
titleComponent?: ReactElement;
216219

@@ -484,6 +487,7 @@ function MenuItem({
484487
focused = false,
485488
disabled = false,
486489
title,
490+
accessibilityLabel,
487491
titleComponent,
488492
titleContainerStyle,
489493
subtitle,
@@ -567,6 +571,7 @@ function MenuItem({
567571
const isCompact = viewMode === CONST.OPTION_MODE.COMPACT;
568572
const isDeleted = style && Array.isArray(style) ? style.includes(styles.offlineFeedbackDeleted) : false;
569573
const descriptionVerticalMargin = shouldShowDescriptionOnTop ? styles.mb1 : styles.mt1;
574+
const defaultAccessibilityLabel = (shouldShowDescriptionOnTop ? [description, title] : [title, description]).filter(Boolean).join(', ');
570575

571576
const combinedTitleTextStyle = StyleUtils.combineStyles<TextStyle>(
572577
[
@@ -754,7 +759,7 @@ function MenuItem({
754759
disabled={disabled || isExecuting}
755760
ref={mergeRefs(ref, popoverAnchor)}
756761
role={role}
757-
accessibilityLabel={title ? title.toString() : ''}
762+
accessibilityLabel={accessibilityLabel ?? defaultAccessibilityLabel}
758763
accessible={shouldBeAccessible}
759764
tabIndex={tabIndex}
760765
onFocus={onFocus}

src/components/PopoverMenu.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {GestureResponderEvent, LayoutChangeEvent, StyleProp, TextStyle, Vie
77
import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager';
88
import useKeyboardShortcut from '@hooks/useKeyboardShortcut';
99
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
10+
import useLocalize from '@hooks/useLocalize';
1011
import usePrevious from '@hooks/usePrevious';
1112
import useResponsiveLayout from '@hooks/useResponsiveLayout';
1213
import useStyleUtils from '@hooks/useStyleUtils';
@@ -287,6 +288,7 @@ function BasePopoverMenu({
287288
const styles = useThemeStyles();
288289
const theme = useTheme();
289290
const StyleUtils = useStyleUtils();
291+
const {translate} = useLocalize();
290292
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to apply correct popover styles
291293
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
292294
const {isSmallScreenWidth} = useResponsiveLayout();
@@ -344,6 +346,7 @@ function BasePopoverMenu({
344346
const previousMenuItems = getPreviousSubMenu();
345347
const previouslySelectedItem = previousMenuItems[enteredSubMenuIndexes[enteredSubMenuIndexes.length - 1]];
346348
const hasBackButtonText = !!previouslySelectedItem?.backButtonText;
349+
const backButtonTitle = hasBackButtonText ? previouslySelectedItem?.backButtonText : previouslySelectedItem?.text;
347350

348351
return (
349352
<MenuItem
@@ -352,7 +355,8 @@ function BasePopoverMenu({
352355
iconFill={(isHovered) => (isHovered ? theme.iconHovered : theme.icon)}
353356
style={hasBackButtonText ? styles.pv0 : undefined}
354357
additionalIconStyles={[{width: variables.iconSizeSmall, height: variables.iconSizeSmall}, styles.opacitySemiTransparent, styles.mr1]}
355-
title={hasBackButtonText ? previouslySelectedItem?.backButtonText : previouslySelectedItem?.text}
358+
title={backButtonTitle}
359+
accessibilityLabel={`${translate('common.goBack')}, ${backButtonTitle}`}
356360
titleStyle={hasBackButtonText ? styles.createMenuHeaderText : undefined}
357361
shouldShowBasicTitle={hasBackButtonText}
358362
shouldCheckActionAllowedOnPress={false}

src/components/SelectionList/ListItem/BaseListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function BaseListItem<TItem extends ListItem>({
112112
}}
113113
disabled={isDisabled && !item.isSelected}
114114
interactive={item.isInteractive}
115-
accessibilityLabel={item.accessibilityLabel ?? item.text ?? ''}
115+
accessibilityLabel={item.accessibilityLabel ?? [item.text, item.text !== item.alternateText ? item.alternateText : undefined].filter(Boolean).join(', ')}
116116
role={getButtonRole(true)}
117117
isNested
118118
hoverDimmingValue={1}

src/components/SelectionListWithSections/BaseListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function BaseListItem<TItem extends ListItem>({
107107
}}
108108
disabled={isDisabled && !item.isSelected}
109109
interactive={item.isInteractive}
110-
accessibilityLabel={item.text ?? ''}
110+
accessibilityLabel={[item.text, item.text !== item.alternateText ? item.alternateText : undefined].filter(Boolean).join(', ')}
111111
role={getButtonRole(true)}
112112
isNested
113113
hoverDimmingValue={1}

src/languages/de.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ const translations: TranslationDeepObject<typeof en> = {
970970
buttonFind: 'Etwas suchen …',
971971
buttonMySettings: 'Meine Einstellungen',
972972
fabNewChat: 'Chat starten',
973-
fabNewChatExplained: 'Chat starten (Schwebende Aktion)',
973+
fabNewChatExplained: 'Aktionsmenü öffnen',
974974
fabScanReceiptExplained: 'Beleg scannen (Schwebende Aktion)',
975975
chatPinned: 'Chat angeheftet',
976976
draftedMessage: 'Entwurfsnachricht',

src/languages/en.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,8 @@ const translations = {
955955
buttonFind: 'Find something...',
956956
buttonMySettings: 'My settings',
957957
fabNewChat: 'Start chat',
958-
fabNewChatExplained: 'Start chat (Floating action)',
959-
fabScanReceiptExplained: 'Scan receipt (Floating action)',
958+
fabNewChatExplained: 'Open actions menu',
959+
fabScanReceiptExplained: 'Scan receipt',
960960
chatPinned: 'Chat pinned',
961961
draftedMessage: 'Drafted message',
962962
listOfChatMessages: 'List of chat messages',

0 commit comments

Comments
 (0)