From 3c2bb3e90a26a441b78eab5051f98d6d19623b56 Mon Sep 17 00:00:00 2001 From: Eli White Date: Fri, 19 Jan 2018 12:50:45 -0800 Subject: [PATCH] TouchableWithoutFeedback will use child's nativeID if specified Reviewed By: sahrens Differential Revision: D6733834 fbshipit-source-id: 409acf8d33565aa1e6d4698fd5d2db046a6f9402 --- .../Components/Touchable/TouchableWithoutFeedback.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/Libraries/Components/Touchable/TouchableWithoutFeedback.js index d3ae834e2..3f9027596 100755 --- a/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -12,6 +12,7 @@ 'use strict'; const EdgeInsetsPropType = require('EdgeInsetsPropType'); +const NativeMethodsMixin = require('NativeMethodsMixin'); const React = require('React'); const PropTypes = require('prop-types'); /* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error @@ -45,7 +46,7 @@ const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; */ const TouchableWithoutFeedback = createReactClass({ displayName: 'TouchableWithoutFeedback', - mixins: [TimerMixin, Touchable.Mixin], + mixins: [NativeMethodsMixin, TimerMixin, Touchable.Mixin], propTypes: { accessible: PropTypes.bool, @@ -159,8 +160,7 @@ const TouchableWithoutFeedback = createReactClass({ }, touchableGetLongPressDelayMS: function(): number { - return this.props.delayLongPress === 0 ? 0 : - this.props.delayLongPress || 500; + return this.props.delayLongPress != null ? this.props.delayLongPress : 500; }, touchableGetPressOutDelayMS: function(): number { @@ -184,7 +184,8 @@ const TouchableWithoutFeedback = createReactClass({ const style = (Touchable.TOUCH_TARGET_DEBUG && child.type && child.type.displayName === 'Text') ? [child.props.style, {color: 'red'}] : child.props.style; - return (React: any).cloneElement(child, { + + return React.cloneElement(child, { accessible: this.props.accessible !== false, accessibilityLabel: this.props.accessibilityLabel, accessibilityComponentType: this.props.accessibilityComponentType, @@ -193,6 +194,7 @@ const TouchableWithoutFeedback = createReactClass({ testID: this.props.testID, onLayout: this.props.onLayout, hitSlop: this.props.hitSlop, + ...child.props, onStartShouldSetResponder: this.touchableHandleStartShouldSetResponder, onResponderTerminationRequest: this.touchableHandleResponderTerminationRequest, onResponderGrant: this.touchableHandleResponderGrant,