Skip to content
Closed
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
36 changes: 26 additions & 10 deletions Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -92,6 +108,7 @@ const TouchableWithoutFeedback = ((createReactClass({
accessibilityComponentType: PropTypes.oneOf(
DeprecatedAccessibilityComponentTypes,
),
accessibilityIgnoresInvertColors: PropTypes.bool,
accessibilityRole: PropTypes.oneOf(DeprecatedAccessibilityRoles),
accessibilityStates: PropTypes.arrayOf(
PropTypes.oneOf(DeprecatedAccessibilityStates),
Expand Down Expand Up @@ -239,18 +256,17 @@ const TouchableWithoutFeedback = ((createReactClass({
Touchable.renderDebugView({color: 'red', hitSlop: this.props.hitSlop}),
);
}

const overrides = {};
for (const prop of OVERRIDE_PROPS) {

Choose a reason for hiding this comment

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

Cannot get this.props[prop] because property accessibilityIgnoresInvertColors is missing in propTypes of React component [1].

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,
Expand Down