I started a fresh react-native 0.40.0 project and added an index view with a Text label and an TextInput contained inside a KeyboardAvoidingView with behavior set to padding. Opening the keyboard made the TextInput animate smoothly to where it should be, but the Text just skipped there (didn't animate).
https://www.dropbox.com/s/cbqv9sve1k6fa3k/react_native-keyboard_avoiding_view-bug.mov?dl=0
import React from 'react';
import {
StyleSheet,
Text,
TextInput,
View,
KeyboardAvoidingView
} from 'react-native';
const styles = StyleSheet.create({
view: {
padding: 20,
flex: 1,
justifyContent: 'center'
},
inputContainer: {
flex: 1,
justifyContent: 'center'
},
label: {
fontFamily: 'helvetica neue',
fontSize: 18
},
input: {
backgroundColor: '#ddd',
height: 30,
fontSize: 18
}
});
function IndexView() {
return (
<KeyboardAvoidingView style={styles.view} behavior="padding">
<View style={styles.inputContainer}>
<Text style={styles.label}>
Some label
</Text>
<TextInput style={styles.input} />
</View>
</KeyboardAvoidingView>
);
}
export default IndexView;
I expected everything to animate as smoothly as the TextInput did.
Wrapping TextInput with View component fixed this issue for me
I am experiencing the same issue only with a FlatList, it's height is not animated (the same behavior as with your Text element):
<KeyboardAvoidingView style={{flex: 1}} behavior={'padding'}>
<FlatList {...props} />
<TextInput style={{height: 50, alignSelf: 'stretch'}} />
</KeyboardAvoidingView>
Wrapping TextInput with a View does not solve it.
@grundmanise I was experiencing exactly the same issue as @thomaslindstrom
Wrapping the Text with a View solved this issue for me. Maybe try doing the same with your FlatList
<KeyboardAvoidingView style={{ flex: 1 }} behavior="padding">
<View>
<FlatList {...props} />
</View>
<TextInput style={{ height: 50, alignSelf: 'stretch' }} />
</KeyboardAvoidingView>
@jackcutting does not work with FlatList/ScrollView
https://github.com/facebook/react-native/issues/13076
I'm experiencing this issue as well. Any updates on this yet?
+1
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!
If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.
Im having the same issue with a FlatList wrapped in a KeyboardAvoidingView. I have a flatlist of inputs, which works fine for the bottom input at the bottom of the screen, the keyboard pushes the bottom input up. But it doesnt work for the item at the top of the list - the keyboard pushes the item out of view.
Most helpful comment
@jackcutting does not work with
FlatList/ScrollViewhttps://github.com/facebook/react-native/issues/13076