Skip to content
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: added aria-modal as alias for accessibilityViewIsModal(iOS) #34506

5 changes: 5 additions & 0 deletions Libraries/Components/Pressable/Pressable.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Props = $ReadOnly<{|
accessibilityState?: ?AccessibilityState,
accessibilityValue?: ?AccessibilityValue,
accessibilityViewIsModal?: ?boolean,
'aria-modal'?: ?boolean,
accessible?: ?boolean,

/**
Expand Down Expand Up @@ -247,6 +248,10 @@ function Pressable(props: Props, forwardedRef): React.Node {
...restProps,
...android_rippleConfig?.viewProps,
accessible: accessible !== false,
accessibilityViewIsModal:
restProps['aria-modal'] !== null
? restProps['aria-modal']
: restProps.accessibilityViewIsModal,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
restProps['aria-modal'] !== null
? restProps['aria-modal']
: restProps.accessibilityViewIsModal,
restProps['aria-modal'] ?? restProps.accessibilityViewIsModal,

accessibilityLiveRegion,
accessibilityState: _accessibilityState,
focusable: focusable !== false,
Expand Down
6 changes: 5 additions & 1 deletion Libraries/Components/Touchable/TouchableBounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ class TouchableBounce extends React.Component<Props, State> {
? 'no-hide-descendants'
: this.props.importantForAccessibility
}
accessibilityViewIsModal={this.props.accessibilityViewIsModal}
accessibilityViewIsModal={
this.props['aria-modal'] !== null
? this.props['aria-modal']
: this.props.accessibilityViewIsModal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.props['aria-modal'] !== null
? this.props['aria-modal']
: this.props.accessibilityViewIsModal
this.props['aria-modal'] ?? this.props.accessibilityViewIsModal

}
accessibilityElementsHidden={
this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden
}
Expand Down
6 changes: 5 additions & 1 deletion Libraries/Components/Touchable/TouchableHighlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,12 @@ class TouchableHighlight extends React.Component<Props, State> {
? 'no-hide-descendants'
: this.props.importantForAccessibility
}
accessibilityViewIsModal={
this.props['aria-modal'] !== null
? this.props['aria-modal']
: this.props.accessibilityViewIsModal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.props['aria-modal'] !== null
? this.props['aria-modal']
: this.props.accessibilityViewIsModal
this.props['aria-modal'] ?? this.props.accessibilityViewIsModal

}
accessibilityLiveRegion={accessibilityLiveRegion}
accessibilityViewIsModal={this.props.accessibilityViewIsModal}
accessibilityElementsHidden={
this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden
}
Expand Down
5 changes: 4 additions & 1 deletion Libraries/Components/Touchable/TouchableNativeFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,11 @@ class TouchableNativeFeedback extends React.Component<Props, State> {
this.props['aria-hidden'] === true
? 'no-hide-descendants'
: this.props.importantForAccessibility,
accessibilityViewIsModal:
this.props['aria-modal'] !== null
? this.props['aria-modal']
: this.props.accessibilityViewIsModal,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.props['aria-modal'] !== null
? this.props['aria-modal']
: this.props.accessibilityViewIsModal,
this.props['aria-modal'] ?? this.props.accessibilityViewIsModal,

accessibilityLiveRegion: accessibilityLiveRegion,
accessibilityViewIsModal: this.props.accessibilityViewIsModal,
accessibilityElementsHidden:
this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden,
hasTVPreferredFocus: this.props.hasTVPreferredFocus,
Expand Down
6 changes: 5 additions & 1 deletion Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,12 @@ class TouchableOpacity extends React.Component<Props, State> {
? 'no-hide-descendants'
: this.props.importantForAccessibility
}
accessibilityViewIsModal={
this.props['aria-modal'] !== null
? this.props['aria-modal']
: this.props.accessibilityViewIsModal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.props['aria-modal'] !== null
? this.props['aria-modal']
: this.props.accessibilityViewIsModal
this.props['aria-modal'] ?? this.props.accessibilityViewIsModal

}
accessibilityLiveRegion={accessibilityLiveRegion}
accessibilityViewIsModal={this.props.accessibilityViewIsModal}
accessibilityElementsHidden={
this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden
}
Expand Down
2 changes: 2 additions & 0 deletions Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Props = $ReadOnly<{|
accessibilityState?: ?AccessibilityState,
accessibilityValue?: ?AccessibilityValue,
accessibilityViewIsModal?: ?boolean,
'aria-modal'?: ?boolean,
accessible?: ?boolean,
/**
* alias for accessibilityState
Expand Down Expand Up @@ -92,6 +93,7 @@ const PASSTHROUGH_PROPS = [
'accessibilityRole',
'accessibilityValue',
'accessibilityViewIsModal',
'aria-modal',
'hitSlop',
'importantForAccessibility',
'nativeID',
Expand Down
9 changes: 9 additions & 0 deletions Libraries/Components/View/ViewPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,15 @@ type IOSViewProps = $ReadOnly<{|
*/
accessibilityViewIsModal?: ?boolean,

/**
* The aria-modal attribute indicates content contained within a modal with aria-modal="true"
* should be accessible to the user.
* Default is `false`.
*
* @platform ios
*/
'aria-modal'?: ?boolean,

/**
* A value indicating whether the accessibility elements contained within
* this accessibility element are hidden.
Expand Down