Skip to content

Conversation

@draperunner
Copy link
Contributor

Currently, AccessibilityInfo.setAccessibilityFocus is 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:

if (Platform.OS === 'ios') {
     AccessibilityInfo.setAccessibilityFocus(reactTag)
} else {
     UIManager.sendAccessibilityEvent(reactTag, 8)
}

With this change, the following is enough for both Android and iOS:

AccessibilityInfo.setAccessibilityFocus(reactTag)

Test Plan:

I made the same change in the react-native package 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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 16, 2018
@mdvacca
Copy link
Contributor

mdvacca commented Jul 17, 2018

Thank you for this PR @draperunner.
I added a small comment.
Can you also update the documentation in: https://facebook.github.io/react-native/docs/accessibilityinfo#setaccessibilityfocus

Thank you!

* See http://facebook.github.io/react-native/docs/accessibilityinfo.html#setaccessibilityfocus
*/
setAccessibilityFocus: function(reactTag: number): void {
UIManager.sendAccessibilityEvent(reactTag, 8);
Copy link
Contributor

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:

and then use that new constant from here

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

Copy link
Contributor

@mdvacca mdvacca left a 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.

@draperunner
Copy link
Contributor Author

Awesome, thanks! Here is the documentation PR: facebook/react-native-website#461

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Jul 17, 2018
@react-native-bot
Copy link
Collaborator

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 master tag, it is not yet part of a release.

@facebook facebook locked as resolved and limited conversation to collaborators Jul 19, 2018
@react-native-bot react-native-bot added the Merged This PR has been merged. label Jul 19, 2018
@hramos hramos removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Feb 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants