FaridSafi/react-native-gifted-chat

Is there a way to manually dismiss the keyboard?

operate2v opened this issue · 8 comments

Is there a way to manually dismiss the keyboard?
For example, if you type certain text, the keyboard dismisses.

  • React Native version: 0.49.3
  • react-native-gifted-chat version: latest
  • Platform(s) (iOS, Android, or both?): both

import dismissKeyboard from 'dismissKeyboard';

// for dismiss keyboard on your event:
dismissKeyboard();

Worked excellent !!!
Thanks...
LordFord.

I close this issue but create a FAQ in readme to refer it: https://github.com/FaridSafi/react-native-gifted-chat#questions

Sorry I don't understand where to put "import dismissKeyboard from 'dismissKeyboard';" and "dismissKeyboard();", can you help me please ?

You should use module Keyboard from react-native to hide keyboard.

import { Keyboard } from 'react-native';

Keyboard.dismiss();

Thank your for your response !

My research was finally "how to remove the keyboard", and I've finally succeeded with those 2 lines in the props :
renderInputToolbar={() => {}}
minInputToolbarHeight={0}

I've another question (sorry I don't know where else to post it) :
Is there a way to pass a function when I press the screen (because if I put a as parent it doesn't scroll anymore).

Thank you !

How did you guys detect user when pressing out of the textinput?
I noticed on android the keyboard stays even when I tried pressing out

@kerubkim, I'm not sure that you need detect press out of textinput. If you want to hide keyboard on tap on scrollview, you can use keyboardShouldPersistTaps='never' ScrollView prop.

If you really want to handle click out of input, you can try onStartShouldSetResponderCapture prop for view. Add it to some root view, and function will be triggered on every screen touch