[0.64] Add Functionality to setAccessibilityFocus Method #8594
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
Current implementation of setAccessibilityFocus method resulted in no action. Request to backport from partner.
What
The RN setAccessibilityFocus API is intended to force the narrator focus to a specific element and then trigger narrator to announce that element.
How
Added source code to the sendAccessibilityEvent method inside PaperUIManager. New source code identifies the new element to focus on via its reactTag, focuses the element, and raises an automation event to alert narrator of the focus change. The RN setAccessibilityFocus API now calls the native method.
Testing
Tested by modifying a page in the playground app to call setAccessibilityFocus following the press of a button. The focus target was a second button. With narrator on, the first button was focused and pressed, triggering the API, and moving narrator focus to the second button. Its component type and accessibility label were then announced. I also ran the playground-win32 app to ensure that the functionality continues to work for XAML islands.
Backport #7268 to 0.64
Microsoft Reviewers: Open in CodeFlow