diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index be072554dc97b2..a78de287e41e77 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -46,6 +46,22 @@ type FocusEvent = TargetEvent; const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; +const OVERRIDE_PROPS = [ + 'accessibilityComponentType', + 'accessibilityLabel', + 'accessibilityHint', + 'accessibilityIgnoresInvertColors', + 'accessibilityRole', + 'accessibilityStates', + 'accessibilityTraits', + 'hitSlop', + 'nativeID', + 'onBlur', + 'onFocus', + 'onLayout', + 'testID', +]; + export type Props = $ReadOnly<{| accessible?: ?boolean, accessibilityComponentType?: ?AccessibilityComponentType, @@ -92,6 +108,7 @@ const TouchableWithoutFeedback = ((createReactClass({ accessibilityComponentType: PropTypes.oneOf( DeprecatedAccessibilityComponentTypes, ), + accessibilityIgnoresInvertColors: PropTypes.bool, accessibilityRole: PropTypes.oneOf(DeprecatedAccessibilityRoles), accessibilityStates: PropTypes.arrayOf( PropTypes.oneOf(DeprecatedAccessibilityStates), @@ -239,18 +256,17 @@ const TouchableWithoutFeedback = ((createReactClass({ Touchable.renderDebugView({color: 'red', hitSlop: this.props.hitSlop}), ); } + + const overrides = {}; + for (const prop of OVERRIDE_PROPS) { + if (this.props[prop] !== undefined) { + overrides[prop] = this.props[prop]; + } + } + return (React: any).cloneElement(child, { + ...overrides, accessible: this.props.accessible !== false, - accessibilityLabel: this.props.accessibilityLabel, - accessibilityHint: this.props.accessibilityHint, - accessibilityComponentType: this.props.accessibilityComponentType, - accessibilityRole: this.props.accessibilityRole, - accessibilityStates: this.props.accessibilityStates, - accessibilityTraits: this.props.accessibilityTraits, - nativeID: this.props.nativeID, - testID: this.props.testID, - onLayout: this.props.onLayout, - hitSlop: this.props.hitSlop, onStartShouldSetResponder: this.touchableHandleStartShouldSetResponder, onResponderTerminationRequest: this .touchableHandleResponderTerminationRequest,