-
Notifications
You must be signed in to change notification settings - Fork 24.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support queuing accessibility announcements on ios (#32637)
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 property [`accessibilitySpeechQueueAnnouncement`](https://developer.apple.com/documentation/foundation/nsattributedstring/key/2865770-accessibilityspeechqueueannounce), so this change just adds an extra parameter to `AccessibilityInfo.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 Pull Request resolved: #32637 Test Plan: I've updated the `announceForAccessibility` section in RNTester with multiple buttons to demonstrate the difference between `queue: false` (default) and `queue: true` and show they work as intended. Here's the expectation for each button: - "Announce for Accessibility Immediately": on press, should start reading the button label, then be interrupted by the announcement - "Announce for Accessibility Queued": on press, should read the button label then read the announcement afterwards - "Announce for Accessibility Queue Multiple": on press, should read the button label, then read three announcements sequentially, no interruptions You can see the realisation of those expectations in the following video recorded on an iPhone 12 running iOS 15.0.2: https://user-images.githubusercontent.com/14826539/142770536-d57bfd69-eba5-444d-9c89-4bf4851ea062.mov I've also tested the same way on an iPhone 8 running iOS 13.4 and it works exactly the same. Reviewed By: yungsters Differential Revision: D32637989 Pulled By: philIip fbshipit-source-id: 3e90add523f11eb0eb34ea623211249263f257e2
- Loading branch information
1 parent
2bb91ae
commit 4d13579
Showing
5 changed files
with
110 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters