Skip to content

Commit

Permalink
feat: added aria-modal as alias for accessibilityViewIsModal(iOS) (#3…
Browse files Browse the repository at this point in the history
…4506)

Summary:
This adds the `aria-modal` prop to the components where it's used as requested on #34424, mapping web [aria-modal](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-modal) to equivalent [accessibilityViewIsModal](iOS)

## Changelog
[General] [Added] - Add aria-modal  prop to basic component

## TestPlan
Checked manually we are receiving the values by props.

Pull Request resolved: #34506

Reviewed By: jacdebug

Differential Revision: D39060396

Pulled By: cipolleschi

fbshipit-source-id: 80da100ff412b17ba29ddc6d811afb4b0207ac9f
  • Loading branch information
Daksh Bhardwaj authored and facebook-github-bot committed Sep 12, 2022
1 parent 3120ae0 commit 095f19a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Libraries/Components/Pressable/Pressable.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type Props = $ReadOnly<{|
'aria-valuenow'?: AccessibilityValue['now'],
'aria-valuetext'?: AccessibilityValue['text'],
accessibilityViewIsModal?: ?boolean,
'aria-modal'?: ?boolean,
accessible?: ?boolean,

/**
Expand Down Expand Up @@ -265,6 +266,8 @@ function Pressable(props: Props, forwardedRef): React.Node {
...restProps,
...android_rippleConfig?.viewProps,
accessible: accessible !== false,
accessibilityViewIsModal:
restProps['aria-modal'] ?? restProps.accessibilityViewIsModal,
accessibilityLiveRegion,
accessibilityLabel,
accessibilityState: _accessibilityState,
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/Touchable/TouchableBounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ class TouchableBounce extends React.Component<Props, State> {
? 'no-hide-descendants'
: this.props.importantForAccessibility
}
accessibilityViewIsModal={this.props.accessibilityViewIsModal}
accessibilityViewIsModal={
this.props['aria-modal'] ?? this.props.accessibilityViewIsModal
}
accessibilityElementsHidden={
this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden
}
Expand Down
4 changes: 3 additions & 1 deletion Libraries/Components/Touchable/TouchableHighlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,10 @@ class TouchableHighlight extends React.Component<Props, State> {
? 'no-hide-descendants'
: this.props.importantForAccessibility
}
accessibilityViewIsModal={
this.props['aria-modal'] ?? this.props.accessibilityViewIsModal
}
accessibilityLiveRegion={accessibilityLiveRegion}
accessibilityViewIsModal={this.props.accessibilityViewIsModal}
accessibilityElementsHidden={
this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden
}
Expand Down
3 changes: 2 additions & 1 deletion Libraries/Components/Touchable/TouchableNativeFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,9 @@ class TouchableNativeFeedback extends React.Component<Props, State> {
this.props['aria-hidden'] === true
? 'no-hide-descendants'
: this.props.importantForAccessibility,
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
4 changes: 3 additions & 1 deletion Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,10 @@ class TouchableOpacity extends React.Component<Props, State> {
? 'no-hide-descendants'
: this.props.importantForAccessibility
}
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 @@ -45,6 +45,7 @@ type Props = $ReadOnly<{|
'aria-valuenow'?: AccessibilityValue['now'],
'aria-valuetext'?: AccessibilityValue['text'],
accessibilityViewIsModal?: ?boolean,
'aria-modal'?: ?boolean,
accessible?: ?boolean,
/**
* alias for accessibilityState
Expand Down Expand Up @@ -102,6 +103,7 @@ const PASSTHROUGH_PROPS = [
'aria-valuenow',
'aria-valuetext',
'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

0 comments on commit 095f19a

Please sign in to comment.