Skip to content

Commit

Permalink
Add rejectResponderTermination prop to TextInput (#16755)
Browse files Browse the repository at this point in the history
Summary:
This is a new attempt to get #11251 merged. I just cherry-picked the relevant commits. TextInputs are set to always ignore responder termination requests, which is not desirable when they are enclosed inside a swipeable area like a ListView

Create a TextInput inside a ListView and set the `rejectResponderTermination` prop to false. Otherwise, all TextInputs should have the same behavior they do now.

[IOS] [ENHANCEMENT] [TextInput] - Add `rejectResponderTermination` prop to to TextInput. This enables TextInputs inside Swipeables to function properly.
Pull Request resolved: #16755

Differential Revision: D7846365

Pulled By: cpojer

fbshipit-source-id: eb21140061ae1f475fbd83fc63a23819e931787d
  • Loading branch information
cmcewen authored and facebook-github-bot committed Jan 28, 2019
1 parent 7cbdd7b commit 11df0ea
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,15 @@ const TextInput = createReactClass({
*/
inlineImagePadding: PropTypes.number,

/**
* If `true`, allows TextInput to pass touch events to the parent component.
* This allows components such as SwipeableListView to be swipeable from the TextInput on iOS,
* as is the case on Android by default.
* If `false`, TextInput always asks to handle the input (except when disabled).
* @platform ios
*/
rejectResponderTermination: PropTypes.bool,

/**
* Determines the types of data converted to clickable URLs in the text input.
* Only valid if `multiline={true}` and `editable={false}`.
Expand Down Expand Up @@ -859,6 +868,7 @@ const TextInput = createReactClass({
getDefaultProps() {
return {
allowFontScaling: true,
rejectResponderTermination: true,
underlineColorAndroid: 'transparent',
};
},
Expand Down Expand Up @@ -1079,7 +1089,7 @@ const TextInput = createReactClass({
<TouchableWithoutFeedback
onLayout={props.onLayout}
onPress={this._onPress}
rejectResponderTermination={true}
rejectResponderTermination={props.rejectResponderTermination}
accessible={props.accessible}
accessibilityLabel={props.accessibilityLabel}
accessibilityRole={props.accessibilityRole}
Expand Down

0 comments on commit 11df0ea

Please sign in to comment.