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.54k stars 61 forks source link

feat: react on selection changes in `KeyboardAwareScrollView` #508

Closed kirillzyusko closed 1 month ago

kirillzyusko commented 1 month ago

📜 Description

KeyboardAwareScrollView is reacting on text selection now.

💡 Motivation and Context

Sometimes users may scroll up, and then they may want to select part of the text. If the text is hidden under the keyboard, then they do not need what to select, they have to scroll themself, and it makes UX worse. In this PR we automatically detect selection event and scroll down to make sure selected text is visible.

Initially I wanted to scroll in the same manner as we do for text change - i.e. just scroll to make TextInput to be above the keyboard. While it works I thought on how it could be improved: since we have selection coordinates we can re-use them and rely on them instead of the height of the input. In this case we will scroll only for selection distance. I experimented a little bit with this approach, it works so I decided to stick to it.

Closes https://github.com/kirillzyusko/react-native-keyboard-controller/issues/420

📢 Changelog

JS

iOS

Android

Docs

E2E

🤔 How Has This Been Tested?

Tested on iPhone 15 Pro, Pixel 2 (API 28, API 31).

📸 Screenshots (if appropriate):

image

📝 Checklist

github-actions[bot] commented 1 month ago

📊 Package size report

Current size Target Size Difference
145744 bytes 144411 bytes 1333 bytes 📈
github-actions[bot] commented 1 month ago

PR Preview Action v1.4.7 :---: Preview removed because the pull request was closed. 2024-07-18 12:06 UTC

argos-ci[bot] commented 1 month ago

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 👍 Changes approved 2 changed Jul 18, 2024, 11:22 AM