After exiting the TextInput, it scrolls the view back to the top of the screen, which is bad when the user was just in the middle of a long scrollview. Is there a way I can disable this behavior? I'd simply like it to stay in place after exiting the TextInput.
Would be better if it was just an option in the library, but this hack solution works for me:
Note: I am using NativeBase library where <Content> uses this library.
I keep the current scroll position in my state via onScroll. I then access this keyboard aware scroll view via refs, and set resetCoords there manually to the current scroll position.
handleScroll(event) {
this.setState({ scrollY: event.nativeEvent.contentOffset.y });
}
render() {
_.set(this.refs, 'Content._scrollview.resetCoords', { x: 0, y: this.state.scrollY });
return (
<Content
ref="Content"
onScroll={event => this.handleScroll(event)}
>
);
}
We are encountering this strange behavior as well. In my opinion this is a bug. Is it really intended or expected to scroll all the way to the top of the view after closing the keyboard?
Sorry for the lack of support, pretty busy right now. I'll check this out because we're seeing some similar issues in a current project we're working on.
I think a similar problem is happening to me. I'm navigating (changing focus) through different text inputs using the return key on the keyboard. As I press it, the view goes slightly up, to then come back down again to the target input. Is this related? It seems it's some kind of delay in the animation, e.g: resetting scroll at first but then "oh right, I need to go down". I already tried to use scrollToFocusedInput but this problem persists
Try using disableKBDismissScroll prop on the Native Base Content component. It works for me.
<Content disableKBDismissScroll={true}>
This is really strange, I can't repro the issue in the iOS Simulator, it correctly saves the latest scroll position and respects it when the keyboard is dismissed.
Somehow, when running this on the device, it doesn't saves the latest scroll position https://github.com/APSL/react-native-keyboard-aware-scroll-view/blob/master/lib/KeyboardAwareScrollView.js#L37
I think I'll release a version that enables the component to disable resetScrollToCoords. How do you feel about that? @booboothefool @TSMMark @fplgusmao
@alvaromb yeah I think that would be a good option, since it does not always make sense using, but can come in handy for other cases
@alvaromb I haven't fully dived into exploring the behaviors of the keyboard aware scroll view so I will not comment much, but that sounds reasonable to me.
I was having this issue on Android only; setting enableResetScrollToCoords={false} fixes it.
Hi,
I am setting enableResetScrollToCoords={false} on iOS 12.1, RN 0.57 and react-native-keyboard-aware-scroll-view 0.7.4 and it is NOT working. I see the same issue as @fplgusmao mentioned: I'm in a form with multiple text inputs and when the user taps the "next" keyboard button while Field3 has focus, then the keyboard-aware-scrollview scrolls up to the top, then down to Field4. It should NOT be scrolling up to the top. This leads to a very janky experience.
Any ideas how to fix this @alvaromb ? Thanks! :-)
Hmm, it seems to behave a lot better if I set blurOnSubmit={false} on my TextInput elements, but then they don't behave as desired if the user just taps on a single input as opposed to next-buttoning between them ... Just wanted to add this in case it might help others.
Most helpful comment
I was having this issue on Android only; setting
enableResetScrollToCoords={false}fixes it.