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

Resolve merge conflicts #84

Open
wants to merge 1 commit into
base: accessibility-role
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 112 additions & 4 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2727,17 +2727,125 @@ const CONST = {
EXPENSIFY_LOGO_SIZE_RATIO: 0.22,
EXPENSIFY_LOGO_MARGIN_RATIO: 0.03,
},
/**
* Acceptable values for the `accessibilityRole` prop on react native components.
*
* **IMPORTANT:** Do not use with the `role` prop as it can cause errors.
*
* @deprecated ACCESSIBILITY_ROLE is deprecated. Please use CONST.ROLE instead.
*/
ACCESSIBILITY_ROLE: {
/**
* @deprecated Please stop using the accessibilityRole prop and use the role prop instead.
*/
BUTTON: 'button',

/**
* @deprecated Please stop using the accessibilityRole prop and use the role prop instead.
*/
LINK: 'link',

/**
* @deprecated Please stop using the accessibilityRole prop and use the role prop instead.
*/
MENUITEM: 'menuitem',
TEXT: 'presentation',

/**
* @deprecated Please stop using the accessibilityRole prop and use the role prop instead.
*/
TEXT: 'text',

/**
* @deprecated Please stop using the accessibilityRole prop and use the role prop instead.
*/
RADIO: 'radio',
IMAGEBUTTON: 'img button',

/**
* @deprecated Please stop using the accessibilityRole prop and use the role prop instead.
*/
IMAGEBUTTON: 'imagebutton',

/**
* @deprecated Please stop using the accessibilityRole prop and use the role prop instead.
*/
CHECKBOX: 'checkbox',

/**
* @deprecated Please stop using the accessibilityRole prop and use the role prop instead.
*/
SWITCH: 'switch',

/**
* @deprecated Please stop using the accessibilityRole prop and use the role prop instead.
*/
ADJUSTABLE: 'adjustable',

/**
* @deprecated Please stop using the accessibilityRole prop and use the role prop instead.
*/
IMAGE: 'image',
},
/**
* Acceptable values for the `role` attribute on react native components.
*
* **IMPORTANT:** Not for use with the `accessibilityRole` prop, as it accepts different values, and new components
* should use the `role` prop instead.
*/
ROLE: {
/** Use for elements with important, time-sensitive information. */
ALERT: 'alert',
/** Use for elements that act as buttons. */
BUTTON: 'button',
/** Use for elements representing checkboxes. */
CHECKBOX: 'checkbox',
/** Use for elements that allow a choice from multiple options. */
COMBOBOX: 'combobox',
/** Use with scrollable lists to represent a grid layout. */
GRID: 'grid',
/** Use for section headers or titles. */
HEADING: 'heading',
/** Use for image elements. */
IMG: 'img',
/** Use for elements that navigate to other pages or content. */
LINK: 'link',
/** Use to identify a list of items. */
LIST: 'list',
/** Use for a list of choices or options. */
MENU: 'menu',
/** Use for a container of multiple menus. */
MENUBAR: 'menubar',
/** Use for items within a menu. */
MENUITEM: 'menuitem',
/** Use when no specific role is needed. */
NONE: 'none',
/** Use for elements that don't require a specific role. */
PRESENTATION: 'presentation',
/** Use for elements showing progress of a task. */
PROGRESSBAR: 'progressbar',
/** Use for radio buttons. */
RADIO: 'radio',
/** Use for groups of radio buttons. */
RADIOGROUP: 'radiogroup',
/** Use for scrollbar elements. */
SCROLLBAR: 'scrollbar',
/** Use for text fields that are used for searching. */
SEARCHBOX: 'searchbox',
/** Use for adjustable elements like sliders. */
SLIDER: 'slider',
/** Use for a button that opens a list of choices. */
SPINBUTTON: 'spinbutton',
/** Use for elements providing a summary of app conditions. */
SUMMARY: 'summary',
/** Use for on/off switch elements. */
SWITCH: 'switch',
ADJUSTABLE: 'slider',
IMAGE: 'img',
/** Use for tab elements in a tab list. */
TAB: 'tab',
/** Use for a list of tabs. */
TABLIST: 'tablist',
/** Use for timer elements. */
TIMER: 'timer',
/** Use for toolbars containing action buttons or components. */
TOOLBAR: 'toolbar',
},
TRANSLATION_KEYS: {
ATTACHMENT: 'common.attachment',
Expand Down
3 changes: 2 additions & 1 deletion src/components/AmountTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function AmountTextInput(props) {
const styles = useThemeStyles();
return (
<TextInput
accessibilityLabel="Text input field"
disableKeyboard
autoGrow
hideFocusedState
Expand All @@ -55,7 +56,7 @@ function AmountTextInput(props) {
blurOnSubmit={false}
selection={props.selection}
onSelectionChange={props.onSelectionChange}
role={CONST.ACCESSIBILITY_ROLE.TEXT}
role={CONST.ROLE.PRESENTATION}
onKeyPress={props.onKeyPress}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function BaseAnchorForAttachmentsOnly(props) {
onPressOut={props.onPressOut}
onLongPress={(event) => showContextMenuForReport(event, anchor, report.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))}
accessibilityLabel={fileName}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
role={CONST.ROLE.BUTTON}
>
<AttachmentView
source={sourceURLWithAuth}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ function BaseAnchorForCommentsOnly({onPressIn, onPressOut, href = '', rel = '',
}}
onPressIn={onPressIn}
onPressOut={onPressOut}
role={CONST.ACCESSIBILITY_ROLE.LINK}
role={CONST.ROLE.LINK}
accessibilityLabel={href}
>
<Tooltip text={href}>
<Text
ref={(el) => (linkRef = el)}
style={StyleSheet.flatten([style, defaultTextStyle])}
role={CONST.ACCESSIBILITY_ROLE.LINK}
role={CONST.ROLE.LINK}
hrefAttrs={{
rel,
target: isEmail || !linkProps.href ? '_self' : target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function CarouselItem({item, isFocused, onPress}) {
<PressableWithoutFeedback
style={[styles.attachmentRevealButtonContainer]}
onPress={onPress}
role={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
accessibilityLabel={item.file.name || translate('attachmentView.unknownFilename')}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function AttachmentViewImage({source, file, isAuthTokenRequired, loadComplete, o
onPress={onPress}
disabled={loadComplete}
style={[styles.flex1, styles.flexRow, styles.alignSelfStretch]}
role={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
accessibilityLabel={file.name || translate('attachmentView.unknownFilename')}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function AttachmentViewImage({source, file, isAuthTokenRequired, isFocused, isUs
onPress={onPress}
disabled={loadComplete}
style={[styles.flex1, styles.flexRow, styles.alignSelfStretch]}
role={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
accessibilityLabel={file.name || translate('attachmentView.unknownFilename')}
>
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarCropModal/AvatarCropModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ function AvatarCropModal(props) {
onLayout={initializeSliderContainer}
onPressIn={(e) => runOnUI(sliderOnPress)(e.nativeEvent.locationX)}
accessibilityLabel="slider"
role={CONST.ACCESSIBILITY_ROLE.ADJUSTABLE}
role={CONST.ROLE.SLIDER}
>
<Slider
sliderValue={translateSlider}
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarWithImagePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function AvatarWithImagePicker({
<Tooltip text={translate('avatarWithImagePicker.editImage')}>
<PressableWithoutFeedback
onPress={() => setIsMenuVisible((prev) => !prev)}
role={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
accessibilityLabel={translate('avatarWithImagePicker.editImage')}
disabled={isAvatarCropModalOpen}
ref={anchorRef}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function Badge({success = false, error = false, pressable = false, text, environ
<Wrapper
style={pressable ? wrapperStyles : wrapperStyles({focused: false, hovered: false, isDisabled: false, isScreenReaderActive: false, pressed: false})}
onPress={onPress}
role={pressable ? CONST.ACCESSIBILITY_ROLE.BUTTON : CONST.ACCESSIBILITY_ROLE.TEXT}
role={pressable ? CONST.ROLE.BUTTON : CONST.ROLE.PRESENTATION}
accessibilityLabel={pressable ? text : undefined}
aria-label={!pressable ? text : undefined}
accessible={false}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function Banner({text, onClose, onPress, containerStyles, textStyles, shouldRend
<Tooltip text={translate('common.close')}>
<PressableWithFeedback
onPress={onClose}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
role={CONST.ROLE.BUTTON}
accessibilityLabel={translate('common.close')}
>
<Icon src={Expensicons.Close} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function Button(
]}
id={id}
accessibilityLabel={accessibilityLabel}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
role={CONST.ROLE.BUTTON}
hoverDimmingValue={1}
>
{renderContent()}
Expand Down
2 changes: 1 addition & 1 deletion src/components/CollapsibleSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function CollapsibleSection({title, children}: CollapsibleSectionProps) {
<PressableWithFeedback
onPress={toggleSection}
style={[styles.pb4, styles.flexRow]}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
role={CONST.ROLE.BUTTON}
accessibilityLabel={title}
hoverDimmingValue={1}
pressDimmingValue={0.2}
Expand Down
2 changes: 1 addition & 1 deletion src/components/CurrencySymbolButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function CurrencySymbolButton({onCurrencyButtonPress, currencySymbol}) {
<PressableWithoutFeedback
onPress={onCurrencyButtonPress}
accessibilityLabel={translate('common.selectCurrency')}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
role={CONST.ROLE.BUTTON}
>
<Text style={styles.iouAmountText}>{currencySymbol}</Text>
</PressableWithoutFeedback>
Expand Down
2 changes: 1 addition & 1 deletion src/components/DatePicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function DatePicker({containerStyles, defaultValue, disabled, errorText, inputID
icon={Expensicons.Calendar}
label={label}
accessibilityLabel={label}
role={CONST.ACCESSIBILITY_ROLE.TEXT}
role={CONST.ROLE.PRESENTATION}
value={value || selectedDate || ''}
placeholder={placeholder || translate('common.dateFormat')}
errorText={errorText}
Expand Down
2 changes: 1 addition & 1 deletion src/components/EmojiPicker/CategoryShortcutButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function CategoryShortcutButton(props) {
onHoverOut={() => setIsHighlighted(false)}
style={({pressed}) => [StyleUtils.getButtonBackgroundColorStyle(getButtonState(false, pressed)), styles.categoryShortcutButton, isHighlighted && styles.emojiItemHighlighted]}
accessibilityLabel={`emojiPicker.headers.${props.code}`}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
role={CONST.ROLE.BUTTON}
>
<Icon
fill={theme.icon}
Expand Down
2 changes: 1 addition & 1 deletion src/components/EmojiPicker/EmojiPickerButtonDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function EmojiPickerButtonDropdown(props) {
onPress={onPress}
id="emojiDropdownButton"
accessibilityLabel="statusEmoji"
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
role={CONST.ROLE.BUTTON}
>
{({hovered, pressed}) => (
<View style={styles.emojiPickerButtonDropdownContainer}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/EmojiPicker/EmojiPickerMenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ function EmojiPickerMenu(props) {
<TextInput
label={translate('common.search')}
accessibilityLabel={translate('common.search')}
role={CONST.ACCESSIBILITY_ROLE.TEXT}
role={CONST.ROLE.PRESENTATION}
onChangeText={filterEmojis}
defaultValue=""
ref={searchInputRef}
Expand Down
2 changes: 1 addition & 1 deletion src/components/EmojiPicker/EmojiPickerMenu/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function EmojiPickerMenu({preferredLocale, onEmojiSelected, preferredSkinTone, t
<TextInput
label={translate('common.search')}
accessibilityLabel={translate('common.search')}
role={CONST.ACCESSIBILITY_ROLE.TEXT}
role={CONST.ROLE.PRESENTATION}
onChangeText={filterEmojis}
blurOnSubmit={filteredEmojis.length > 0}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/EmojiPicker/EmojiPickerMenuItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class EmojiPickerMenuItem extends PureComponent {
this.props.themeStyles.emojiItem,
]}
accessibilityLabel={this.props.emoji}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
role={CONST.ROLE.BUTTON}
>
<Text style={[this.props.themeStyles.emojiText]}>{this.props.emoji}</Text>
</PressableWithoutFeedback>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class EmojiPickerMenuItem extends PureComponent {
this.props.themeStyles.emojiItem,
]}
accessibilityLabel={this.props.emoji}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
role={CONST.ROLE.BUTTON}
>
<Text style={[this.props.themeStyles.emojiText]}>{this.props.emoji}</Text>
</PressableWithoutFeedback>
Expand Down
2 changes: 1 addition & 1 deletion src/components/EmojiPicker/EmojiSkinToneList.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function EmojiSkinToneList(props) {
onPress={toggleIsSkinToneListVisible}
style={[styles.flexRow, styles.alignSelfCenter, styles.justifyContentStart, styles.alignItemsCenter]}
accessibilityLabel={props.translate('emojiPicker.skinTonePickerLabel')}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
role={CONST.ROLE.BUTTON}
>
<View style={[styles.emojiItem, styles.wAuto, styles.justifyContentCenter]}>
<Text style={[styles.emojiText, styles.ph2, styles.textNoWrap]}>{currentSkinTone.code}</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function ImageRenderer(props) {
ReportUtils.isArchivedRoom(report),
)
}
role={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
>
<ThumbnailImage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function MentionUserRenderer(props) {
event.preventDefault();
Navigation.navigate(navigationRoute);
}}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.LINK}
role={CONST.ROLE.LINK}
accessibilityLabel={`/${navigationRoute}`}
>
<UserDetailsTooltip
Expand All @@ -77,7 +77,7 @@ function MentionUserRenderer(props) {
>
<Text
style={[styles.link, _.omit(props.style, 'color'), StyleUtils.getMentionStyle(isOurMention), {color: StyleUtils.getMentionTextColor(isOurMention)}]}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.LINK}
role={CONST.ROLE.LINK}
testID="span"
href={`/${navigationRoute}`}
// eslint-disable-next-line react/jsx-props-no-spreading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const BasePreRenderer = forwardRef((props, ref) => {
onPressIn={props.onPressIn}
onPressOut={props.onPressOut}
onLongPress={(event) => showContextMenuForReport(event, anchor, report.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))}
role={CONST.ACCESSIBILITY_ROLE.TEXT}
role={CONST.ROLE.PRESENTATION}
accessibilityLabel={props.translate('accessibilityHints.prestyledText')}
>
<View>
Expand Down
2 changes: 1 addition & 1 deletion src/components/HeaderWithBackButton/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function HeaderWithBackButton({
<PressableWithoutFeedback
onPress={onCloseButtonPress}
style={[styles.touchableButtonImage]}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
role={CONST.ROLE.BUTTON}
accessibilityLabel={translate('common.close')}
>
<Icon
Expand Down
2 changes: 1 addition & 1 deletion src/components/ImageView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function ImageView({isAuthTokenRequired, url, fileName, onError}) {
}}
onPressIn={onContainerPressIn}
onPress={onContainerPress}
role={CONST.ACCESSIBILITY_ROLE.IMAGE}
role={CONST.ROLE.IMG}
accessibilityLabel={fileName}
>
<Image
Expand Down
2 changes: 1 addition & 1 deletion src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function OptionRowLHN(props) {
props.isFocused ? styles.sidebarLinkActive : null,
(hovered || isContextMenuActive) && !props.isFocused ? props.hoverStyle || styles.sidebarLinkHover : null,
]}
role={CONST.ACCESSIBILITY_ROLE.BUTTON}
role={CONST.ROLE.BUTTON}
accessibilityLabel={translate('accessibilityHints.navigatesToChat')}
needsOffscreenAlphaCompositing={props.optionItem.icons.length >= 2}
>
Expand Down
Loading