-
Notifications
You must be signed in to change notification settings - Fork 25k
Make AccessibilityInfo.setAccessibilityFocus cross platform #20229
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
Make AccessibilityInfo.setAccessibilityFocus cross platform #20229
Conversation
|
Thank you for this PR @draperunner. Thank you! |
| * See http://facebook.github.io/react-native/docs/accessibilityinfo.html#setaccessibilityfocus | ||
| */ | ||
| setAccessibilityFocus: function(reactTag: number): void { | ||
| UIManager.sendAccessibilityEvent(reactTag, 8); |
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.
Instead of set the value 8 here, you should export a new constant in UIManagerModuleConstants.AccessibilityEventTypes:
see:
react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModuleConstants.java
Line 138 in 26684cf
| AccessibilityEvent.TYPE_VIEW_CLICKED)); |
and then use that new constant from here
facebook-github-bot
left a comment
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.
@mdvacca has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
mdvacca
left a comment
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.
Great, thanks! I'm importing it.
|
Awesome, thanks! Here is the documentation PR: facebook/react-native-website#461 |
|
This pull request was closed by @draperunner in be715ec. Once this commit is added to a release, you will see the corresponding version tag below the description at be715ec. If the commit has a single |
Currently,
AccessibilityInfo.setAccessibilityFocusis only available on iOS. The same behaviour can be achieved on Android by dispatching the proper accessibility event. I implemented the same function for Android, to make life slightly more convenient for the developer.Today, developers must write something like this:
With this change, the following is enough for both Android and iOS:
Test Plan:
I made the same change in the
react-nativepackage in my project's node_modules, and checked that it worked on an Android device with TalkBack activated.Release Notes:
[ANDROID] [ENHANCEMENT] [AccessibilityInfo] - Implement AccessibilityInfo.setAccessibilityFocus for Android