Skip to content

Commit

Permalink
TextInput: Add onPressIn and onPressOut
Browse files Browse the repository at this point in the history
Summary:
Introduces support for `onPressIn` and `onPressOut` on the `TextInput` component.

This makes it possible to add visual feedback when users touch interact with `TextInput` components.

Changelog:
[General][Added] - TextInput now supports `onPressIn` and `onPressOut`.

Reviewed By: TheSavior

Differential Revision: D23514333

fbshipit-source-id: 1790e977b78f1c293d5476aef8613547f27d6731
  • Loading branch information
yungsters authored and facebook-github-bot committed Sep 8, 2020
1 parent 1b994f9 commit b7b0e23
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,16 @@ export type Props = $ReadOnly<{|
*/
onEndEditing?: ?(e: EditingEvent) => mixed,

/**
* Called when a touch is engaged.
*/
onPressIn?: ?(event: PressEvent) => mixed,

/**
* Called when a touch is released.
*/
onPressOut?: ?(event: PressEvent) => mixed,

/**
* Callback that is called when the text input selection is changed.
* This will be called with
Expand Down Expand Up @@ -1135,6 +1145,8 @@ function InternalTextInput(props: Props): React.Node {
<TouchableWithoutFeedback
onLayout={props.onLayout}
onPress={_onPress}
onPressIn={props.onPressIn}
onPressOut={props.onPressOut}
accessible={props.accessible}
accessibilityLabel={props.accessibilityLabel}
accessibilityRole={props.accessibilityRole}
Expand Down

1 comment on commit b7b0e23

@retyui
Copy link
Contributor

@retyui retyui commented on b7b0e23 Dec 27, 2020

Choose a reason for hiding this comment

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

@yungsters Thank you! That makes less painful my problem and solved without crazy hacks )))

Please sign in to comment.