Commit 407b96c
Allow Switch to use default UISwitch accessibility annoucements (facebook#50796)
Summary:
Pull Request resolved: facebook#50796
When we render a `Switch` today we are never actually focusing on the native `UISwitch` that gets rendered. We instead focus on the parent `RCTViewComponentView` which houses the `UISwitch` as a `contentView`. That is because of [this logic](https://www.internalfb.com/code/fbsource/[b7e1547dab5a]/xplat/js/react-native-github/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm?lines=1211-1213). This blocks the accessibility of any descendants, including the `contentView`.
What we lose here is the announcement of "on" and "off" based on the toggle state that comes built into `UISwitch`. To do this today you need to add `accessibilityState={{checked: ...}}` which is very unintuitive. Android DOES announce "on" and "off".
We can fix this with an override on the switch class.
Changelog: [iOS][Fixed] - Fix "on" and "off" announcements on `Switch`
Reviewed By: realsoelynn
Differential Revision: D732265001 parent 5fd5188 commit 407b96c
File tree
1 file changed
+12
-0
lines changed- packages/react-native/React/Fabric/Mounting/ComponentViews/Switch
1 file changed
+12
-0
lines changedLines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
104 | 116 | | |
105 | 117 | | |
106 | 118 | | |
| |||
0 commit comments