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

UIViewManager: Add accessibilityElementsHidden #10918

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 20 additions & 23 deletions Libraries/Components/View/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if (Platform.isTVOS) {
TVViewPropTypes = require('TVViewPropTypes');
}

const deprecatedPropType = require('deprecatedPropType');
const requireNativeComponent = require('requireNativeComponent');

const PropTypes = React.PropTypes;
Expand Down Expand Up @@ -190,30 +191,26 @@ const View = React.createClass({
]),

/**
* Controls how view is important for accessibility which is if it
* fires accessibility events and if it is reported to accessibility services
* that query the screen. Works for Android only.
*
* Possible values:
*
* - `'auto'` - The system determines whether the view is important for accessibility -
* default (recommended).
* - `'yes'` - The view is important for accessibility.
* - `'no'` - The view is not important for accessibility.
* - `'no-hide-descendants'` - The view is not important for accessibility,
* nor are any of its descendant views.
*
* See the [Android `importantForAccessibility` docs](http://developer.android.com/reference/android/R.attr.html#importantForAccessibility)
* for reference.
*
* @platform android
* Controls whether the accessibility elements contained within this view are hidden
* from accessibility services that query the screen.
*
* - If `true`, this View and all accessibility elements contained within it are hidden
* from accessibility services.
* - If `false`, this view is visible to accessibility services.
* - The default value is `null` which means the OS decides which elements are important
* for accessibility.
*/
importantForAccessibility: PropTypes.oneOf([
'auto',
'yes',
'no',
'no-hide-descendants',
]),
accessibilityElementsHidden: PropTypes.bool,

importantForAccessibility: deprecatedPropType(
PropTypes.oneOf([
'auto',
'yes',
'no',
'no-hide-descendants',
]),
'Use the `accessibilityElementsHidden` prop instead.'
),

/**
* Provides additional traits to screen reader. By default no traits are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class NavigationCard extends React.Component<any, Props, any> {
{...viewPanHandlers}
pointerEvents={pointerEvents}
ref={this.props.onComponentRef}
accessibilityElementsHidden={!props.scene.isActive}
style={[styles.main, viewStyle]}>
{renderScene(props)}
</Animated.View>
Expand Down
1 change: 1 addition & 0 deletions React/Views/RCTViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ - (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(__unused NSDictio
RCT_EXPORT_VIEW_PROPERTY(tvParallaxProperties, NSDictionary)
#endif

RCT_EXPORT_VIEW_PROPERTY(accessibilityElementsHidden, BOOL)
RCT_EXPORT_VIEW_PROPERTY(accessibilityLabel, NSString)
RCT_EXPORT_VIEW_PROPERTY(accessibilityTraits, UIAccessibilityTraits)
RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor)
Expand Down