kirillzyusko / react-native-keyboard-controller

Keyboard manager which works in identical way on both iOS and Android
https://kirillzyusko.github.io/react-native-keyboard-controller/
MIT License
1.4k stars 55 forks source link

`KeyboardAwareScrollView` is not reacting on text selection #420

Open kirillzyusko opened 2 months ago

kirillzyusko commented 2 months ago

Describe the bug

If your multiline input is partially covered by the keyboard and you select text inside this input, then selection can go under the keyboard and you will not understand what you are selecting.

Code snippet

KeyboardAwareScrollView example.

Repo for reproducing

Can be reproduced in example app.

To Reproduce Steps to reproduce the behavior:

  1. Go to KeyboardAwareScrollView example
  2. Click on TextInput#5
  3. Type 10 lines of text
  4. Scroll down, to make visible only one line of the text
  5. Try to select an entire text

Expected behavior

On web for example we have following behavior:

https://github.com/kirillzyusko/react-native-keyboard-controller/assets/22820318/ab82f7fe-8bf9-4ec9-9f3b-41e642a3a7bc

Screenshots

iOS Android

Smartphone (please complete the following information):

Additional context

I think this library should expose additional handler in useFocusedInputHandler:

useFocusedInputHandler({
  onSelectionChange: (e) => {
    "worklet";
  }
});

That will be fired whenever position of the carret will be changed. Also probably we'll need to include x/y coordinates for first and last carret.