-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
adding iOS support for accessibilityLiveRegion #35432
adding iOS support for accessibilityLiveRegion #35432
Conversation
Read documentation, investigate different solutions, plan work (details) -- Test existing react-native accessibilityLiveRegion functionality on Android Paper (details)Include Video recording of different scenarios (assertive, polite, none)Write down expected behaviour for iOS Implementation Design (details) Detect accessibility content change (details) Read documentation, investigate different solutions, plan work ([details](facebook#34735 (comment))) "Test existing react-native accessibilityLiveRegion functionality on Android Paper ([details](facebook#34735 (comment))) Include Video recording of different scenarios (assertive, polite, none) Write down expected behaviour for iOS" Implementation Design ([details](facebook#34735 (comment))) Detect accessibility content change ([details](facebook#34735 (comment)))
Base commit: 46ffeca |
Base commit: 46ffeca |
PR build artifact for 972a40a is ready. |
Add prop accessibilityLiveRegion to react-native iOS API Trigger polite/assertive announcement if label/hint changesdd prop accessibilityLiveRegion to react-native iOS API
PR build artifact for 53f7b76 is ready. |
PR build artifact for 53f7b76 is ready. |
PR build artifact for 85b1c1f is ready. |
PR build artifact for 85b1c1f is ready. |
…bilityLiveRegion to children on iOS. If a view with accessibilityLiveRegion does not have accessibilityLabel, the view announces the child text component. - check if the view does not have accessibilityLabel - Run a loop on each children and add accessibilityLiveRegion if children is focusable https://stackoverflow.com/questions/32370994/how-to-pass-props-to-this-props-children
PR build artifact for 17af1f8 is ready. |
PR build artifact for 17af1f8 is ready. |
…assertive Read Implementation RCTParagraphComponentViewUnderstand logic behind announcement of the accessibilityLabel -- Add announcement for Accessibility State. RCTViewComponent updateProps will save the accessibilityState in self.accessibilityTraits. Use self.accessibilityTraits to announce the change in value from updatePropsRead iOS ImplementationTest the announcement of self.accessibilityTraits with UIAccessibilityPostNotification Read accessibilityValue logic in RCTComponentView Chain Label + Hint + State to avoid cutting announcements when using assertiveCreate a local variables named label, hint, state, roleVerify order used on iOS to announce Label, Hint, State (selected my label Button my hint) => state label role hintAdd Label, Hint and State to accessibilityLiveRegionAnnouncement respecting correct orderTrigger announcement if accessibilityLiveRegionAnnouncement is not empty "Read Implementation RCTParagraphComponentView Understand logic behind announcement of the accessibilityLabel" "Add announcement for Accessibility State. RCTViewComponent updateProps will save the accessibilityState in self.accessibilityTraits. Use self.accessibilityTraits to announce the change in value from updateProps Read iOS Implementation Test the announcement of self.accessibilityTraits with [UIAccessibilityPostNotification](https://github.com/fabriziobertoglio1987/react-native/blob/17af1f8489e202a65c1e20c440756db2be95a8b4/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm#L305)" Read [accessibilityValue logic](https://github.com/fabriziobertoglio1987/react-native/blob/17af1f8489e202a65c1e20c440756db2be95a8b4/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm#L365) in RCTComponentView "Chain Label + Hint + State to avoid cutting announcements when using assertive Create a local variables named label, hint, state, role Verify order used on iOS to announce Label, Hint, State (selected my label Button my hint) => state label role hint Add Label, Hint and State to accessibilityLiveRegionAnnouncement respecting correct order Trigger announcement if accessibilityLiveRegionAnnouncement is not empty "
PR build artifact for 119892c is ready. |
PR build artifact for 119892c is ready. |
PR build artifact for 744408a is ready. |
PR build artifact for 744408a is ready. |
P type task |
Android - correctly announcing change of ariaLive in Text component
2022-12-12.22-02-30.mp4 |
PR build artifact for 88cbc2c is ready. |
PR build artifact for 88cbc2c is ready. |
|
PR build artifact for 133f440 is ready. |
PR build artifact for 133f440 is ready. |
PR build artifact for 59a23ba is ready. |
PR build artifact for 59a23ba is ready. |
Just adding a comment here regarding documentation. I think it would be really valuable to add a warning comment to the docs for both Android and iOS cautioning people to reach for polite over assertive in most cases. Marketers can be prone to abusing assertive live regions on the web and in 90%+ of cases (IMO) polite is the better user experience. cc @blavalla |
@lunaleaps has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This PR is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This PR was closed because it has been stalled for 7 days with no activity. |
Summary
The functionality is included in two components:
RCTViewComponentView
RCTViewComponentView is the Fabric API built on top of iOS UIView. The class will compare the old and new props sent from React fabric renderer and save the values as instance variables like accessibilityLabel, and accessibilityValue on the native iOS components.
Once the update process is completed, the VoiceOver announcement is triggered in finalizeUpdates which is responsible for updating the iOS native User Interface with the new props sent from the react fabric renderer (see RCTMountingManager and react-reconciler).
RCTParagraphComponentView
The native iOS component for Text is RCTParagraphComponentView.
This component's peculiarity is that it overrides the accessibilityLabel of the parent View component with its text value (#34735 (comment)).
ReactNative supports nested Text components represented on iOS as an array of accessibility elements. Updating the accessibility elements attributedText triggers a VoiceOver announcement if accessibilityLiveRegion is enabled.
VoiceOver announces changes in the accessibility attributes of children.
Adding dynamic VoiceOver announcement to iOS RCTViewComponent
The functionality adds VoiceOver dynamic announcements for changes in accessibilityLabel, hint, state, or other attributes of components with the accessibilityLiveRegion prop. Announcements of components with accessibilityLiveRegion polite are queued using UIAccessibilitySpeechAttributeQueueAnnouncement.
RCTParagraphComponent dynamic VoiceOver announcements
The react-native Text Component updates the native iOS attributedText with a special prop named children. The text creation and update are triggered from the Fabric renderer with the methods createTextInstance and updateHostText. updateState invalidates the iOS UIView with setNeedsDisplay. The UIView component retrieves and displays the updated attributedString from the new _state (more code pointers here).
A manual VoiceOver announcement is triggered after the state change to announce the updated Paragraph attributedText.
Other notes
fixes #34735. The below functionalities are moved to a separate PR:
Changelog
[iOS] [Added] - adding iOS support for accessibilityLiveRegion
Test Plan
#35432 (comment)
#35432 (comment)
#35432 (comment)
#35432 (comment)
#35432 (comment)