imnapo / react-native-cn-quill

Quill rich-text editor for react-native
MIT License
185 stars 72 forks source link

Keyboard.dismiss() doesn't work #98

Open lucasmrl opened 2 years ago

lucasmrl commented 2 years ago

Hey! First of all, thanks for this library. It saved me a lot of time so far. :) I'm facing an issue with Keyboard.dismiss() not working using the editor. It works if the keyboard appeared due to a TextInput field, but not for the editor since it's wrapped in a WebView. Any suggestions on how to handle this case?

Thanks!

mannby commented 1 year ago

KeyboardAvoidingView and related components also don't work.

mannby commented 1 year ago

_editor.current.blur() can be used to dismiss the keyboard

stesvis commented 1 year ago

_editor.current.blur() can be used to dismiss the keyboard

But how do you dismiss the keyboard when you tap outside of the editor? Basically like a react-native TextInput... For example in iOS there is no way to dismiss the keyboard

mannby commented 1 year ago

In my experience, if you tap in a TextInput control, that control now gets input from the keyboard.

To dismiss the keyboard anywhere else, you can intercept taps there with a Pressable over the rest of the views and call blur() on the quill editor component.

Usman-Marwat commented 3 weeks ago

Wrap the whole JSX in Pressable and check for Keyboard visibility:

<Pressable
  onPress={() => {
    if (Keyboard.isVisible()) editorRef.current.blur();
  }}
>