KeyboardAvoidingView - When keyboardVerticalOffset is too big, view does not return to initial position.
See original GitHub issueDescription:
When I set the keyboardVerticalOffset of KeyboardAvoidingView to a number higher than ~180, the view does not return properly to the right position when the keyboard disappears. Lower numbers work fine.
React Native version:
System:
OS: macOS 10.15.3
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 116.71 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 13.10.1 - /usr/local/bin/node
npm: 6.13.7 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
npmGlobalPackages:
react-native-cli: 2.0.1
Steps To Reproduce
I am using React-Navigation 5 tabs navigator and nested stack navigator.
App:
<NavigationContainer>
<BottomTab.Navigator>
...
<BottomTab.Screen name="Post" component={AddPostScreen}/>
</BottomTab.Navigator>
</NavigationContainer>
AddPostScreen:
<Stack.Navigator>
<Stack.Screen name="AddInfoStep">
{props => <AddInfoStep {...props} setTitle={this.setTitle} post={this.state} addPost={this.addPost} />}
</Stack.Screen>
...
</Stack.Navigator>
AddInfoStep:
<KeyboardAvoidingView
style={{
alignItems: 'center',
backgroundColor: '#fff',
flex: 1,
justifyContent: 'center',
padding: 30,
}}
behavior="padding"
keyboardVerticalOffset={250}
>
<View style={styles.imageContainer}>
<Image >
</View>
<Formik >
{({setFieldValue, handleBlur, handleSubmit, values, touched, errors }) => (
<>
<FormTextInput />
<Button />
</>
)}
</Formik>
<Link />
</KeyboardAvoidingView>
Expected Results
View should return to initial position.
Snack, code example, screenshot, or link to a repository:
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
KeyboardAvoidingView not Working Properly - Stack Overflow
If you are using react-navigation, this is affected by the header of the react-navigation. The height of the header is vary on different ......
Read more >react native keyboard avoiding view not working - You.com
I am using KeyboardAvoidingView in ios with behavior="padding" but it's not working. My screen has four text input fields, which get hidden by...
Read more >Will we ever be safe from KeyboardAvoidingView? - YouTube
Learn React Native Gestures and Animations at https:// start -react-native.
Read more >Using the KeyboardAvoidingView in React Native
When using the position option, the entire view will be moved 'up'. ... also need a little help from the 'KeyboardVerticalOffset' props too:....
Read more >A Keyboard Avoiding View for React Native in 2021
currentlyFocusedField() can be replaced with TextInputState.currentlyFocusedInput() which returns not a number (like currentlyFocusedField() ) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m facing the same issue. But it’s hard to find the cause to share a reproducible demo.
I am also having this issue — I use react-navigation with a header and bottomTabNavigator. The keyboardVerticalOffset padding seems to just remain present when the keyboard is dismissed.