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.78k stars 81 forks source link

KeyboardAwareScrollView shrinking view #699

Closed JJablonski02 closed 1 week ago

JJablonski02 commented 1 week ago

Describe the bug Surrounding the view with a component KeyboardAwareScrollView it shrinks the view. It works correct when I set hardcoded children components height props, but when children are flexbox containers it doesnt work properly. In some cases we want to shrink view, but in some cases we do not.

Code snippet

**Repo for reproducing** Code snippet should be enough. The only thing I didn't tested is how it works on Ios. I tested it on Android. **To Reproduce** Steps to reproduce the behavior: 1. Copy -> paste code above 2. Open keyboard and watch how content behaves **Expected behavior** Possibility to set the content not to shrink **Screenshots** ![obraz](https://github.com/user-attachments/assets/25bd1807-7471-4a1b-8023-3f163cf99a5e) ![obraz](https://github.com/user-attachments/assets/f205e62d-8a6b-48db-8fb9-0ecaa688337d) **Smartphone:** - Desktop OS: Windows 11 - Device: Pixel 8 Vanilla API - RN version: 0.74.3 - RN architecture: new - JS engine: Hermes - Library version: 1.14.4
kirillzyusko commented 1 week ago

@JJablonski02 the possible solution in your case is to wrap children of KeyboardAwareScrollView inside additional View and specify minHeight. In this case autoshrinking will be fixed.

The problem why it happens is because I embed an additional View inside KeyboardAwareScrollView (and I increase size of this view when keyboard is shown - it's necessary to give an ability to scroll to the bottom when keyboard is shown). And when I increase the size of this view - the available space becomes smaller and your views gets shrinked.

The issue you are referring to was described in https://github.com/kirillzyusko/react-native-keyboard-controller/issues/168

I wish contentInset property of ScrollView would exist on Android - in this I could have a cross-platform code that wouldn't have breaking changes comparing to original implementation of KeyboardAwareScrollView πŸ˜”

JJablonski02 commented 1 week ago

Thank you @kirillzyusko. It worked as I expected :)

kirillzyusko commented 1 week ago

Awesome @JJablonski02 😎

I'm going to close that issue then. I wish my implementation wouldn't have a breaking changes, but contentInset on Android is a blocker here at the moment πŸ˜”