-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix announceForAccessibility #7220
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
Fix announceForAccessibility #7220
Conversation
| element = xamlRoot.Content(); | ||
| } | ||
| } | ||
| auto textBlock = xaml::Controls::TextBlock(); |
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.
nit: seems like a UIElement might be enough - https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.automation.peers.frameworkelementautomationpeer.fromelement?view=winrt-19041
Would be a little cheaper to create - can you try that?
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.
you can't instantiate UIElement directly, only subclasses
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.
Should I leave it as is? Or is there a cheaper subclass I should instantiate instead?
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.
I think it might work with a Control
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.
Ok looks like Control also can't be instantiated directly only its subclasses.
Summary: Cherry picks: microsoft#5849 microsoft#7220 microsoft#7290 Test Plan: See D29689294 Test Plan Reviewers: ericroz Reviewed By: ericroz Subscribers: eliwhite Differential Revision: https://phabricator.intern.facebook.com/D30940769 Tasks: T85606613 Signature: 30940769:1631724353:41db1d978132f06502803cfb4df0323f6da84732
Resolve #5908
Why
announceForAccessibility method in the AccessibilityInfo module failed to announce messages.
What
The API for the method does not include a reference to a RN component as a parameter but Windows requires an element to announce from. The previous implementation tried to pass in Xaml::Window::Content into FrameworkElementAutomationPeer::FromElement to create an automation peer, but this approach always resulted in the peer being null and no announcement could be made.
Altered the code such that a Xaml Control (TextBlock) is passed into FrameworkElementAutomationPeer::FromElement instead. This caused the peer returned to be non-null and the announcement could be fired.
Testing
Created an RNW app and altered Microsoft.ReactNative inside of tester app with the changes to AccessibilityInfo. Was able to hear announcement when announceForAccessibility was called.
Microsoft Reviewers: Open in CodeFlow