Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rejectResponderTermination prop to TextInput #11251

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Add rejectResponderTermination prop to TextInput
  • Loading branch information
adamski committed Mar 16, 2018
commit 9eb9cfc95cc67012fa85ace23e764402328d8c23
17 changes: 13 additions & 4 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,12 @@ const TextInput = createReactClass({
*/
inlineImagePadding: PropTypes.number,

/**
* Allow TextInput to pass touch event to parent.
Copy link
Contributor

@mkonicek mkonicek Mar 15, 2017

Choose a reason for hiding this comment

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

I don't understand this comment. Could you extend it please explaining how and why someone would want to use this prop?

EDIT: I understand it now but only after reading the summary in this PR. Without it people will probably not know what this doc block means.

Copy link
Author

Choose a reason for hiding this comment

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

OK, will update the comment, thanks

* @platform ios
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this iOS only? Looks like a JS change. Does it not work on Android?

Copy link
Author

Choose a reason for hiding this comment

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

It does not make any difference on Android, where the default behaviour is for a TextInput to pass the touch event to the parent.

*/
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 @@ -601,11 +607,14 @@ const TextInput = createReactClass({
*/
caretHidden: PropTypes.bool,
},

getDefaultProps(): Object {
return {
rejectResponderTermination: false,
allowFontScaling: true,
};
},

/**
* `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We
* make `this` look like an actual native component class.
Expand Down Expand Up @@ -770,7 +779,7 @@ const TextInput = createReactClass({
<TouchableWithoutFeedback
onLayout={props.onLayout}
onPress={this._onPress}
rejectResponderTermination={true}
rejectResponderTermination={props.rejectResponderTermination}
accessible={props.accessible}
accessibilityLabel={props.accessibilityLabel}
accessibilityTraits={props.accessibilityTraits}
Expand Down Expand Up @@ -859,9 +868,9 @@ const TextInput = createReactClass({
// Make sure to fire the mostRecentEventCount first so it is already set on
// native when the text value is set.
if (this._inputRef) {
this._inputRef.setNativeProps({
mostRecentEventCount: event.nativeEvent.eventCount,
});
this._inputRef.setNativeProps({
mostRecentEventCount: event.nativeEvent.eventCount,
});
}

var text = event.nativeEvent.text;
Expand Down