Closed johnf closed 11 months ago
If I move the input down, so enough of it is covered by the keyboard Which means that after the keyboard comes up, soft input initiates a scroll event Then I can scroll down to the button
For the demo, I've forked this repo and adjusted the FORM example.
I am facing the same issue only on Android. Attaching video you reference. Follow the steps to reproduce it.
Input on screen at top.
No scroll on the initial screen (As mentioned above -> Fit data on screen)
Focus on input and the keyboard will show up while some listing data is hidden behind the keyboard (Show in video)
Now try to scroll down (To view the list data which is hidden behind the keyboard).
The scroll will not work. There will be two things that happen if you try to scroll.
If you have added keyboardShouldPersistTaps='always'
. Nothing will happen (Scroll will not work and the keyboard will shown as it is)
Otherwise, keyboard will hide.
Screen will be scrollable when Keyboard is shown as some data is hidden behind the Keyboard.
Hey @johnf @saadi-ninjasCode, thx for reporting the issue!
I managed to reproduce it and did some investigation in the library's Android code. It turned out that it has something to do with the library, but rather with how Android's ScrollView
class works.
When the scrollview's content has height less or equal to scrollview's height and the scrollY position is equal 0, then the scrollview is not scrollable even when bottom padding is applied.
It turned out that canScrollVertically
helper, which is used internally in ScrollView
, returns false
even when bottom padding is applied. I tried to hack it with scrolling by 1dp and it helped partially - I was able to scroll to the bottom of the scrollview, but then when I scrolled to the top, the scrollview was stuck again (above helper again returned false
)
I don't think, it should be responsibility of the library to fix weird/broken behavior of stock ScrollView
and I don't see any other way apart from creating custom class that extends ScrollView
, which I don't want to do and later maintain.
So at the end, I think that will be a won't fix 😕
As a workaround for use cases when the scrollview's content has smaller or equal height to the scrollview's height, you can manually apply the padding to some Animated.View
like described in Sticky Footer recipe - put the empty Animated.View
inside your ScrollView
at the bottom as a last child view and apply the padding to that Animated.View
with useSoftInputHeightChanged
hook
Environment
Library version: 4.0.1 OS version: Android 14 in emulator
Affected platforms
Current behavior
Expected behavior
I should be able to scroll to the button
Reproduction
https://github.com/johnf/react-native-avoid-softinput/tree/main