Repository navigation
fix(View): map aria-modal to accessibilityViewIsModal - #59328
faciledictu wants to merge 1 commit into
Conversation
|
Hi @faciledictu! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D126904378. |
|
This pull request was successfully merged by @faciledictu in e3437cb When will my fix make it into a release? | How to file a pick request? |
Summary: The `View` docs list `aria-modal` as an iOS prop that "has precedence over the `accessibilityViewIsModal` prop". `View` does not map it, though: `View.js` converts `aria-label`, `aria-live`, `aria-hidden` and the other `aria-*` props to their `accessibility*` forms, but `aria-modal` is passed through unchanged, and the native side only reads `accessibilityViewIsModal`. As a result `<View aria-modal>` does nothing, and VoiceOver can still reach the views behind a custom dialog. When `aria-modal` was added in react#34506, it was mapped in `Pressable` and the `Touchable*` components and added to `ViewPropTypes`, but `View.js` itself was not changed, so the prop is typed and documented on `View` but has no effect there. This change maps `aria-modal` to `accessibilityViewIsModal` in `View`, with `aria-modal` taking precedence, as documented. ## Changelog: [IOS] [FIXED] - `aria-modal` on `View` now sets `accessibilityViewIsModal` Pull Request resolved: react#59328 Test Plan: Checked on an iPhone (iOS 27) with React Native 0.88.0 (Expo SDK 58, development build), VoiceOver on. A screen with three background buttons and a custom overlay that is their sibling: ```tsx import { useState } from 'react'; import { Pressable, Text, View } from 'react-native'; export default function App() { const [open, setOpen] = useState(false); return ( <View style={{ flex: 1 }}> <View style={{ flex: 1, padding: 48, gap: 16 }}> {['One', 'Two', 'Three'].map((title) => ( <Pressable key={title} role="button"> <Text>Background item {title}</Text> </Pressable> ))} <Pressable role="button" onPress={() => setOpen(true)}> <Text>Open the dialog</Text> </Pressable> </View> {open && ( <View aria-modal style={{ position: 'absolute', inset: 0, justifyContent: 'center', padding: 32, backgroundColor: 'rgba(0,0,0,0.4)', }} > <View style={{ backgroundColor: 'white', padding: 24, gap: 16 }}> <Text role="heading">Dialog</Text> <Pressable role="button" onPress={() => setOpen(false)}> <Text>Close</Text> </Pressable> </View> </View> )} </View> ); } ``` Before: with the dialog open, swiping right goes past "Close" to the "Background item" buttons, and touching where they are focuses them. Replacing `aria-modal` with `accessibilityViewIsModal` keeps focus inside the dialog. After: `aria-modal` behaves the same as `accessibilityViewIsModal`. Reviewed By: andrewdacenko Differential Revision: D126904378 Pulled By: javache fbshipit-source-id: 698cceaa5ad45c68c6fd9eb7fa002da4901a7aa1
Summary:
The
Viewdocs listaria-modalas an iOS prop that "has precedence over theaccessibilityViewIsModalprop".Viewdoes not map it, though:View.jsconverts
aria-label,aria-live,aria-hiddenand the otheraria-*propsto their
accessibility*forms, butaria-modalis passed through unchanged,and the native side only reads
accessibilityViewIsModal. As a result<View aria-modal>does nothing, and VoiceOver can still reach the viewsbehind a custom dialog.
When
aria-modalwas added in #34506, it was mapped inPressableand theTouchable*components and added toViewPropTypes, butView.jsitself wasnot changed, so the prop is typed and documented on
Viewbut has no effectthere.
This change maps
aria-modaltoaccessibilityViewIsModalinView, witharia-modaltaking precedence, as documented.Changelog:
[IOS] [FIXED] -
aria-modalonViewnow setsaccessibilityViewIsModalTest Plan:
Checked on an iPhone (iOS 27) with React Native 0.88.0 (Expo SDK 58,
development build), VoiceOver on. A screen with three background buttons and a
custom overlay that is their sibling:
Before: with the dialog open, swiping right goes past "Close" to the
"Background item" buttons, and touching where they are focuses them.
Replacing
aria-modalwithaccessibilityViewIsModalkeeps focus inside thedialog.
After:
aria-modalbehaves the same asaccessibilityViewIsModal.