-
Notifications
You must be signed in to change notification settings - Fork 3k
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
17004 - add new ESLint rules to enforce use of accessible pressable components #20363
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
@@ -15,7 +15,6 @@ class TextInputLabel extends PureComponent { | |||
return ( | |||
<Animated.Text | |||
pointerEvents="none" | |||
accessibilityRole="label" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
label
accessibility role doesn't exist. In the latest commit, I changed it to text
value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -9,6 +9,8 @@ import * as StyleUtils from '../../../../styles/StyleUtils'; | |||
import {withNavigationPropTypes} from '../../../../components/withNavigation'; | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
ref={(el) => (this.label = el)} | ||
pointerEvents="none" | ||
accessibilityRole={CONST.ACCESSIBILITY_ROLE_TEXT} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accessibilityRole={CONST.ACCESSIBILITY_ROLE_TEXT} | |
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Skalakid we missed this and need to make this change ASAP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@situchan @roryabraham I'm not sure what the suggested change is, can you explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONST.ACCESSIBILITY_ROLE_TEXT
is undefined. It should be CONST.ACCESSIBILITY_ROLE.TEXT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Skalakid please look with 🦅's 👁️ to find diff 😄
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.39-11 🚀
|
@@ -49,6 +49,7 @@ function AmountTextInput(props) { | |||
blurOnSubmit={false} | |||
selection={props.selection} | |||
onSelectionChange={props.onSelectionChange} | |||
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming from #24482 (comment):
Do we need accessibilityRole
for text input?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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
/PressableWithoutFeedback
npm run lint
if 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 apressable
prop 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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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