17004 - add new ESLint rules to enforce use of accessible pressable components#20363
Conversation
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
|
@rushatgabhane Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
rushatgabhane
left a comment
There was a problem hiding this comment.
Code LGTM and tests well. I don't think this needs a C+ review tho.
@roryabraham
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #17004... Please reach out for help on Slack if no one gets assigned! |
| return ( | ||
| <Animated.Text | ||
| pointerEvents="none" | ||
| accessibilityRole="label" |
There was a problem hiding this comment.
Why did we remove this?
There was a problem hiding this comment.
label accessibility role doesn't exist. In the latest commit, I changed it to text value
roryabraham
left a comment
There was a problem hiding this comment.
NAB but is there an easy way to configure a global default accessibilityRole for TextInput? Every time it seems we use accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT} and wonder if we can DRY things up by using a lightweight TextInput wrapper that adds a default accessibility role. And then add a new ESLint rule to enforce that we use our own TextInput rather than the default from RN
| import styles from '../../../../styles/styles'; | ||
| import CONST from '../../../../CONST'; | ||
| import PressableWithoutFeedback from '../../../../components/Pressable/PressableWithoutFeedback'; | ||
| import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize'; |
There was a problem hiding this comment.
Can we use the useLocalize hook instead of withLocalize HOC?
|
@roryabraham I don't know if it is possible. The plugin that we are using is checking components only by names. So it is checking both I think we can fix that by just changing the name of our TextInput component, and then pass |
|
@Skalakid ok no worries, we can proceed without the default |
|
Conflicts |
|
@roryabraham I just fixed the conflicts |
|
@Skalakid Sorry, conflicts were back by the time I got to this. |
|
@roryabraham I fixed conflicts again ;) |
Reviewer Checklist
Screenshots/VideosWebMobile Web - ChromeMobile Web - SafariDesktopiOSAndroid |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 1.3.39-0 🚀
|
|
@Skalakid @roryabraham @rushatgabhane Can you pls help with a more understandable QA steps. Current tests are move Dev specific. |
|
@mvtglobally this PR is really DEV-specific because we are adding ESlint rules so that developers can see errors in their IDE while coding |
| pointerEvents="none" | ||
| ref={(el) => (this.label = el)} | ||
| pointerEvents="none" | ||
| accessibilityRole={CONST.ACCESSIBILITY_ROLE_TEXT} |
There was a problem hiding this comment.
| accessibilityRole={CONST.ACCESSIBILITY_ROLE_TEXT} | |
| accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT} |
There was a problem hiding this comment.
@Skalakid we missed this and need to make this change ASAP
There was a problem hiding this comment.
@situchan @roryabraham I'm not sure what the suggested change is, can you explain?
There was a problem hiding this comment.
CONST.ACCESSIBILITY_ROLE_TEXT is undefined. It should be CONST.ACCESSIBILITY_ROLE.TEXT
There was a problem hiding this comment.
@Skalakid please look with 🦅's 👁️ to find diff 😄
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.39-11 🚀
|
| blurOnSubmit={false} | ||
| selection={props.selection} | ||
| onSelectionChange={props.onSelectionChange} | ||
| accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT} |
There was a problem hiding this comment.
Coming from #24482 (comment):
Do we need accessibilityRole for text input?
There was a problem hiding this comment.
There was a problem hiding this comment.
@aimane-chnaif It is a crucial prop from the accessibility perspective. It is needed to avoid ESlint errors since all accessibility components are required to have accessibilityRole
There was a problem hiding this comment.
@Skalakid can we change it to presentation which means none if it is just to avoid ESlint errors?
There was a problem hiding this comment.
@getusha I think you can try or you can change accessibilityRole to accessibilityLabel if you want. But it's strange that such an error appears since according to the documentation text role exists
There was a problem hiding this comment.
@Skalakid accessibility* props are deprecated we are trying to change it to the role prop check it here: https://reactnative.dev/docs/accessibility#role
Details
Fixed Issues
$ #17004
PROPOSAL: #17004
Tests
PressableWithFeedback/PressableWithoutFeedbacknpm run lintif there are no errors connected with accessibility. Currently, there should be about 7 errors in components that will be migrated but in other tasksIn this PR I also included the migration of the last components to PressableWithoutFeedback:
Badge
pressable={true}prop, to test it add apressableprop to any Badge componentThreePaneView
FloatingActionButton
Verify that no errors appear in the JS console
Offline tests
Same as Tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
web.mov
Mobile Web - Chrome
mWeb-chrome.mov
Mobile Web - Safari
mWeb-safari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
android.mov