Skip to content

Commit

Permalink
fix: Updated accessibility role for buttons (#8753)
Browse files Browse the repository at this point in the history
## **Description**
- Updated accessibility role for buttons and text inside buttons
- Enabled 'Text' to accept accessibilityRole

## **Related issues**

Fixes: #8630 

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've clearly explained what problem this PR is solving and how it
is solved.
- [x] I've linked related issues
- [ ] I've included manual testing steps
- [ ] I've included screenshots/recordings if applicable
- [ ] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
- [x] I’ve properly set the pull request status:
  - [ ] In case it's not yet "ready for review", I've set it to "draft".
- [ ] In case it's "ready for review", I've changed it from "draft" to
"non-draft".

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
brianacnguyen authored Feb 28, 2024
1 parent 7f214af commit 70eff9c
Show file tree
Hide file tree
Showing 23 changed files with 104 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ exports[`CustomSpendCap should match snapshot 1`] = `
</View>
</View>
<Text
accessibilityRole="text"
accessibilityRole="link"
accessible={true}
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
Expand Down Expand Up @@ -220,7 +221,8 @@ exports[`CustomSpendCap should match snapshot 1`] = `
This allows the third party to spend all your token balance until it reaches the cap or you revoke the spending cap. If this is not intended, consider setting a lower spending cap.
<Text
accessibilityRole="text"
accessibilityRole="link"
accessible={true}
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ exports[`Banner should render correctly with a close button 1`] = `
Sample Banner Description
</Text>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down Expand Up @@ -385,6 +387,8 @@ exports[`Banner should render correctly with an action button 1`] = `
Sample Banner Description
</Text>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ exports[`BannerAlert should render BannerAlert 1`] = `
Sample Banner Alert Description
</Text>
<Text
accessibilityRole="text"
accessibilityRole="link"
accessible={true}
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ exports[`BannerTip should render default settings correctly 1`] = `
Sample Banner Tip Description
</Text>
<Text
accessibilityRole="text"
accessibilityRole="link"
accessible={true}
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ exports[`BottomSheetFooter should render snapshot correctly 1`] = `
testID="bottomsheetfooter"
>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down Expand Up @@ -52,6 +54,8 @@ exports[`BottomSheetFooter should render snapshot correctly 1`] = `
</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const ButtonBase = ({
activeOpacity={1}
onPress={onPress}
style={styles.base}
accessibilityRole="button"
accessible
{...props}
>
{startIconName && (
Expand All @@ -59,6 +61,7 @@ const ButtonBase = ({
<Text
variant={DEFAULT_BUTTONBASE_LABEL_TEXTVARIANT}
style={styles.label}
accessibilityRole="none"
>
{label}
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

exports[`ButtonBase should render correctly 1`] = `
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
style={
Expand All @@ -28,6 +30,7 @@ exports[`ButtonBase should render correctly 1`] = `
}
/>
<Text
accessibilityRole="none"
style={
Object {
"color": "#24272A",
Expand All @@ -42,6 +45,8 @@ exports[`ButtonBase should render correctly 1`] = `

exports[`ButtonBase should render correctly when disabled 1`] = `
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
disabled={true}
onPress={[Function]}
Expand Down Expand Up @@ -70,6 +75,7 @@ exports[`ButtonBase should render correctly when disabled 1`] = `
}
/>
<Text
accessibilityRole="none"
style={
Object {
"color": "#24272A",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const ButtonLink: React.FC<ButtonLinkProps> = ({
onPressIn={triggerOnPressedIn}
onPressOut={triggerOnPressedOut}
accessibilityRole="link"
accessible
{...props}
>
{renderLabel()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`Link should render correctly 1`] = `
<Fragment>
<Text
accessibilityRole="link"
accessible={true}
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
Expand Down
2 changes: 1 addition & 1 deletion app/component-library/components/Texts/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Text: React.FC<TextProps> = ({
}) => {
const { styles } = useStyles(styleSheet, { variant, style, color });
return (
<RNText {...props} style={styles.base} accessibilityRole="text">
<RNText accessibilityRole="text" {...props} style={styles.base}>
{children}
</RNText>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ exports[`CollectibleModal should render correctly 1`] = `
}
>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ exports[`NetworkDetails renders correctly 1`] = `
testID="bottomsheetfooter"
>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down Expand Up @@ -543,6 +545,8 @@ exports[`NetworkDetails renders correctly 1`] = `
</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ exports[`NetworkVerificationInfo renders correctly 1`] = `
testID="bottomsheetfooter"
>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPressIn={[Function]}
onPressOut={[Function]}
Expand Down Expand Up @@ -501,6 +503,8 @@ exports[`NetworkVerificationInfo renders correctly 1`] = `
</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPressIn={[Function]}
onPressOut={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,8 @@ exports[`NetworkSwitcher View renders and dismisses network modal when pressing
testID="bottomsheetfooter"
>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down Expand Up @@ -1371,6 +1373,8 @@ exports[`NetworkSwitcher View renders and dismisses network modal when pressing
</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down
6 changes: 6 additions & 0 deletions app/components/UI/Tokens/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ exports[`Tokens should hide zero balance tokens when setting is on 1`] = `
0 USD
</Text>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down Expand Up @@ -1433,6 +1435,8 @@ exports[`Tokens should render correctly 1`] = `
0 USD
</Text>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down Expand Up @@ -2436,6 +2440,8 @@ exports[`Tokens should show all balance tokens when hideZeroBalanceTokens settin
0 USD
</Text>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ exports[`EditAccountName should render correctly 1`] = `
}
>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[MockFunction]}
onPressIn={[Function]}
Expand Down Expand Up @@ -218,6 +220,8 @@ exports[`EditAccountName should render correctly 1`] = `
</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
disabled={false}
onPress={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,8 @@ exports[`Network Selector renders correctly 1`] = `
</View>
</RCTScrollView>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Array [
View the list of active WalletConnect sessions
</Text>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down Expand Up @@ -174,7 +176,8 @@ Array [
This is a test feature that blocks any changes to the app's JavaScript code without permission.
<Text
accessibilityRole="text"
accessibilityRole="link"
accessible={true}
onPress={[Function]}
onPressIn={[Function]}
onPressOut={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ Array [
}
>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down Expand Up @@ -154,6 +156,8 @@ Array [
</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down Expand Up @@ -312,6 +316,8 @@ Array [
}
>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down Expand Up @@ -350,6 +356,8 @@ Array [
</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down Expand Up @@ -496,6 +504,8 @@ Array [
}
>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down Expand Up @@ -534,6 +544,8 @@ Array [
</Text>
</TouchableOpacity>
<TouchableOpacity
accessibilityRole="button"
accessible={true}
activeOpacity={1}
onPress={[Function]}
onPressIn={[Function]}
Expand Down
Loading

0 comments on commit 70eff9c

Please sign in to comment.