React-native: KeyboardAvoidingView with padding behavior fails to animate text

Created on 11 Jan 2017  路  8Comments  路  Source: facebook/react-native

Description

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).

Reproduction

Here's a video of the issue:

https://www.dropbox.com/s/cbqv9sve1k6fa3k/react_native-keyboard_avoiding_view-bug.mov?dl=0

This code reproduces the issue:

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;

Solution

I expected everything to animate as smoothly as the TextInput did.

Additional Information

  • React Native version: 0.40.0
  • Platform: iOS 10.2 (Simulator)
  • Operating System: MacOS 10.12.2
iOS Locked

Most helpful comment

@jackcutting does not work with FlatList/ScrollView
https://github.com/facebook/react-native/issues/13076

All 8 comments

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:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

DreySkee picture DreySkee  路  3Comments

aniss picture aniss  路  3Comments

despairblue picture despairblue  路  3Comments

lazywei picture lazywei  路  3Comments