From e90435d8f922fce52a676b4a4ad13efd564274bd Mon Sep 17 00:00:00 2001 From: Alec Larson Date: Fri, 15 Mar 2019 17:16:09 -0400 Subject: [PATCH 1/3] Fix prop overrides of TouchableWithoutFeedback Child props were being overridden by props even when the props were undefined. --- .../Touchable/TouchableWithoutFeedback.js | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index be072554dc97b2..ba3f4d90a81f5e 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -46,6 +46,19 @@ type FocusEvent = TargetEvent; const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; +const OVERRIDE_PROPS = [ + 'accessibilityComponentType', + 'accessibilityLabel', + 'accessibilityHint', + 'accessibilityRole', + 'accessibilityStates', + 'accessibilityTraits', + 'hitSlop', + 'nativeID', + 'onLayout', + 'testID', +]; + export type Props = $ReadOnly<{| accessible?: ?boolean, accessibilityComponentType?: ?AccessibilityComponentType, @@ -239,18 +252,16 @@ 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, { - 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, + ...overrides, onStartShouldSetResponder: this.touchableHandleStartShouldSetResponder, onResponderTerminationRequest: this .touchableHandleResponderTerminationRequest, From 8527cde398022bc1f9c91a7bef028c025fde3760 Mon Sep 17 00:00:00 2001 From: Alec Larson Date: Fri, 15 Mar 2019 17:25:08 -0400 Subject: [PATCH 2/3] Fix unforwarded TouchableWithoutFeedback props --- Libraries/Components/Touchable/TouchableWithoutFeedback.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index ba3f4d90a81f5e..797dbe3f6e8ac1 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -50,11 +50,14 @@ const OVERRIDE_PROPS = [ 'accessibilityComponentType', 'accessibilityLabel', 'accessibilityHint', + 'accessibilityIgnoresInvertColors', 'accessibilityRole', 'accessibilityStates', 'accessibilityTraits', 'hitSlop', 'nativeID', + 'onBlur', + 'onFocus', 'onLayout', 'testID', ]; @@ -105,6 +108,7 @@ const TouchableWithoutFeedback = ((createReactClass({ accessibilityComponentType: PropTypes.oneOf( DeprecatedAccessibilityComponentTypes, ), + accessibilityIgnoresInvertColors: PropTypes.bool, accessibilityRole: PropTypes.oneOf(DeprecatedAccessibilityRoles), accessibilityStates: PropTypes.arrayOf( PropTypes.oneOf(DeprecatedAccessibilityStates), From 4815fb2b50241b8cc1d7eb944c98835a99a58d29 Mon Sep 17 00:00:00 2001 From: Alec Larson Date: Mon, 18 Mar 2019 10:11:46 -0400 Subject: [PATCH 3/3] Fix missing "accessible" prop --- Libraries/Components/Touchable/TouchableWithoutFeedback.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index 797dbe3f6e8ac1..a78de287e41e77 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -266,6 +266,7 @@ const TouchableWithoutFeedback = ((createReactClass({ return (React: any).cloneElement(child, { ...overrides, + accessible: this.props.accessible !== false, onStartShouldSetResponder: this.touchableHandleStartShouldSetResponder, onResponderTerminationRequest: this .touchableHandleResponderTerminationRequest,