-
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
feat: support queuing accessibility announcements on ios #32637
Conversation
@philIip has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Looks good. Thanks for the contribution, @peterc1731. Would you be willing to also submit a similar PR to facebook/react-native-website so that this can be documented? (Your response does not change the fact that we will merge this.) |
@yungsters Yes happy to do that. |
hi @peterc1731, can you rebase when you get the chance? i will go for the land soon. |
25c8066
to
dc7bdd9
Compare
@philIip has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@philIip has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
just a heads up, @peterc1731 i needed to make some changes on top of your PR for backwards compatibility reasons |
This pull request was successfully merged by @peterc1731 in 4d13579. When will my fix make it into a release? | Upcoming Releases |
thanks @philIip, I'll update the linked docs PR to reflect the API changes |
Summary
The current implementation of
AccessibilityInfo.announceForAccessibility
will immediately interrupt any existing in progress speech with the announcement. Sometimes this is desirable behaviour, but often you will want to wait until existing speech is finished before reading the new announcement. This change gives us that option.My personal use case for this feature is a custom text input. When typing on iOS with voiceover enabled, each character is read out after being selected. I wanted to add some additional information after each character to help with the context of what has changed in the input, but I didn't want to override the reading of the character itself.
This feature is supported natively on iOS by constructing an
NSAttributedString
with the propertyaccessibilitySpeechQueueAnnouncement
, so this change just adds an extra parameter toAccessibilityInfo.announceForAccessibility
which controls the value of that property on the native side. Adding this as an extra optional parameter with false as the default ensures that existing uses of the function won't be affected.Unfortunately, this feature doesn't appear to be supported on Android, so the new second property will be iOS only.
Changelog
[iOS] [Added] - add new argument to announceForAccessibility to allow queueing on iOS
Test Plan
I've updated the
announceForAccessibility
section in RNTester with multiple buttons to demonstrate the difference betweenqueue: false
(default) andqueue: true
and show they work as intended.Here's the expectation for each button:
You can see the realisation of those expectations in the following video recorded on an iPhone 12 running iOS 15.0.2:
queue-announcement-demo-2.mov
I've also tested the same way on an iPhone 8 running iOS 13.4 and it works exactly the same.