-
-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KeyboardAvoidingView sibling to KeyboardAwareScrollView creates empty space at the bottom of the KeyboardAwareScrollView #451
Comments
@itsramiel shouldn't you use From a quick look |
I don't think Actually in my case I want the whole screen to be avoiding the keyboard along with the scrollview to keep the focused input visible so I can change my returned jsx to: return (
<KeyboardAvoidingView style={{ flex: 1 }} behavior="padding">
<KeyboardAwareScrollView
style={{ flex: 1 }}
contentContainerStyle={{ gap: 8 }}>
{Array(7)
.fill(0)
.map((_, i) => (
<View key={i} style={{ height: 80, backgroundColor: 'blue' }} />
))}
<TextInput style={{ padding: 16, backgroundColor: 'red' }} />
</KeyboardAwareScrollView>
<Button title="done" />
</KeyboardAvoidingView>
); but I still get the same behavior: Simulator.Screen.Recording.-.iPhone.15.-.2024-05-21.at.18.29.54.mp4changes are on branch alt1 One thing that I tried by mistake and kinda works is to wrap the whole screen with code: return (
<KeyboardAvoidingView style={{flex: 1}} behavior="padding">
<ScrollView style={{flex: 1}} contentContainerStyle={{gap: 8}}>
{Array(7)
.fill(0)
.map((_, i) => (
<View key={i} style={{height: 80, backgroundColor: 'blue'}} />
))}
<TextInput style={{padding: 16, backgroundColor: 'red'}} />
</ScrollView>
<Button title="done" />
</KeyboardAvoidingView>
); video: Simulator.Screen.Recording.-.iPhone.15.-.2024-05-21.at.18.35.23.mp4changes are on branch alt2 Looking forward to you reply! |
Hey @itsramiel Sorry for a long response. Basically when you combine two view (i. e. Regarding wrapping My suggestion would be to stick to example app and use
You always can create your own component, like: const KeyboardAwareScrollViewWithFooter = ({ footer, children }) => {
const [footerOffset, setFooterOffset] = useState(0);
const onLayout = (e) => {
setFooterOffset(e.nativeEvent.layout.height);
};
return (
<>
<KeyboardAwareScrollView>
{children}
</KeyboardAwareScrollView>
<View onLayout={onLayout}>
{footer}
</View>
</>
);
} And use this component in declarative way. Let me know if I'm missing anything 🙏 |
I would have preferred to have a solution without manually measuring the height and applying a bottom padding but if that is the state then alright. Thanks for the response. I will be closing the issue |
Describe the bug
When
KeyboardAvoidingView
is a sibling toKeyboardAwareScrollView
then:KeyboardAwareScrollView
has extra space at the bottom of it (main issue)KeyboardAwareScrollView
is not correctly positioned from the first try, take a bit to adjustCode snippet
What I am trying to achieve is a screen with a list that contains arbitrary views and an input and a footer button. I would like when the user click on the input for it to be focused/visible while also having the button visible to allow the user to take action(done button in footer) without needing to close the keyboard first
Repo for reproducing
https://github.com/itsramiel/keyboard-controller-repro
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expect not to have extra space on the bottom
ScreenRecording
Simulator.Screen.Recording.-.iPhone.15.-.2024-05-21.at.12.46.57.mp4
Smartphone (please complete the following information):
Additional context
I am not sure why the text input also lags a bit behind and is not correctly position from the first time.
The text was updated successfully, but these errors were encountered: