diff --git a/README.md b/README.md index 8e913b697..2887b4db7 100644 --- a/README.md +++ b/README.md @@ -401,6 +401,7 @@ interface QuickReplies { - **`renderAccessory`** _(Function)_ - Custom second line of actions below the message composer - **`onPressActionButton`** _(Function)_ - Callback when the Action button is pressed (if set, the default `actionSheet` will not be used) - **`bottomOffset`** _(Integer)_ - Distance of the chat from the bottom of the screen (e.g. useful if you display a tab bar) +- **`focusOnInputWhenOpeningKeyboard`** _(Bool)_ - Focus on automatically when opening the keyboard; default `true` - **`minInputToolbarHeight`** _(Integer)_ - Minimum height of the input toolbar; default is `44` - **`listViewProps`** _(Object)_ - Extra props to be passed to the messages [``](https://facebook.github.io/react-native/docs/listview.html); some props can't be overridden, see the code in `MessageContainer.render()` for details - **`textInputProps`** _(Object)_ - Extra props to be passed to the [``](https://facebook.github.io/react-native/docs/textinput.html) diff --git a/src/GiftedChat.tsx b/src/GiftedChat.tsx index 90e88a861..953d34d8e 100644 --- a/src/GiftedChat.tsx +++ b/src/GiftedChat.tsx @@ -119,6 +119,8 @@ export interface GiftedChatProps { lightboxProps?: LightboxProps /* Distance of the chat from the bottom of the screen (e.g. useful if you display a tab bar); default is 0 */ bottomOffset?: number + /* Focus on automatically when opening the keyboard; default is true */ + focusOnInputWhenOpeningKeyboard?: boolean /* Minimum height of the input toolbar; default is 44 */ minInputToolbarHeight?: number /* Extra props to be passed to the messages ; some props can't be overridden, see the code in MessageContainer.render() for details */ @@ -253,6 +255,7 @@ function GiftedChat ( renderChatFooter = null, renderInputToolbar = null, bottomOffset = 0, + focusOnInputWhenOpeningKeyboard = true, keyboardShouldPersistTaps = Platform.select({ ios: 'never', android: 'always', @@ -577,10 +580,11 @@ function GiftedChat ( } ) - if (isKeyboardMovingUp) - runOnJS(handleTextInputFocusWhenKeyboardShow)() - else - runOnJS(handleTextInputFocusWhenKeyboardHide)() + if (focusOnInputWhenOpeningKeyboard) + if (isKeyboardMovingUp) + runOnJS(handleTextInputFocusWhenKeyboardShow)() + else + runOnJS(handleTextInputFocusWhenKeyboardHide)() if (value === 0) { runOnJS(enableTyping)() @@ -594,6 +598,7 @@ function GiftedChat ( [ keyboard, trackingKeyboardMovement, + focusOnInputWhenOpeningKeyboard, insets, handleTextInputFocusWhenKeyboardHide, handleTextInputFocusWhenKeyboardShow,