question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android keyboard disappears when TextInput is behind the keyboard area

See original GitHub issue

When you have a FlatList with regular View’s, but upon clicking a View (or touchable) they become TextInput elements, the keyboard won’t properly show for items that are below the next keyboard position. Please see attached GIF for an example

Kapture 2019-12-16 at 22 08 01

React Native version:

info Fetching system and libraries information...
System:
    OS: macOS 10.15.1
    CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
    Memory: 713.34 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 13.3.0 - /usr/local/bin/node
    Yarn: 1.19.2 - /usr/local/bin/yarn
    npm: 6.13.2 - /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
    Android SDK:
      API Levels: 23, 26, 27, 28, 29
      Build Tools: 28.0.3, 29.0.0
      System Images: android-24 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.3/11C29 - /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

  1. Copy code below into a standard project
  2. Tap on one of the items on the lower part of the screen (no need to scroll)
  3. Witness keyboard popping up as expected but then closing immediately

Describe what you expected to happen: I expect the keyboard to appear and the content to be resized so the bottom of the list is still visible, or at the very least have the focussed input element to be scrolled up above the keyboard

Snack, code example, screenshot, or link to a repository:

import React from "react";
import { FlatList, KeyboardAvoidingView, StyleSheet, Text, TextInput, TouchableNativeFeedback, View } from 'react-native';


class TestBrokenStuff extends React.PureComponent {
    public state = {
        searchResults: [],
        editting: null,
    };

    public componentDidMount() {
        const items = [];

        for (let i = 0; i < 100; ++i) {
            items.push('item ' + i);
        }

        this.setState({
            searchResults: items
        });
    }

    public onEdit = (id) => {
        this.setState({
            editting: id,
        });
    };

    public renderTagItem = ({ item }) => {
        return (
            <View style={styles.item}>
                {item === this.state.editting && (
                    <TextInput
                        value={item}
                        autoFocus
                    />
                )}

                {item !== this.state.editting && (
                    <TouchableNativeFeedback onPress={() => this.onEdit(item)}>
                        <Text>{item}</Text>
                    </TouchableNativeFeedback>
                )}
            </View>

        );
    };

    public keyExtractor = (item) => {
        return item;
    };

    public render() {
        const { searchResults } = this.state;

        return (
            <View>
                <KeyboardAvoidingView>
                    <FlatList
                        data={searchResults}
                        renderItem={this.renderTagItem}
                        keyExtractor={this.keyExtractor}
                        keyboardShouldPersistTaps="handled"
                        extraData={this.state.editting}
                    />
                </KeyboardAvoidingView>
            </View>

        );
    }

}

export default TestBrokenStuff;

const styles = StyleSheet.create({
    item: {
        height: 32
    },
});

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:20 (2 by maintainers)

github_iconTop GitHub Comments

16reactions
2333Gecommented, Jul 7, 2020

Flast add removeClippedSubviews={false}

7reactions
plasmarobcommented, Mar 19, 2021

Same issue, took a lot to find this one. Adding the attribute removeClippedSubviews={false} to FlatList does indeed fix it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

EditText disappears when user press on and keyboard appear
EditText disappears when user press on and keyboard appear · try adding your buttons and edit texts to a Scrollview since when the...
Read more >
Handle input method visibility | Android Developers
When input focus moves in or out of an editable text field, Android shows or hides the input method—such as the on-screen keyboard—as ......
Read more >
My keyboard is disappearing while typing How do I Fix it - iFixit
Go to settings>>application manager>>all and find the keyboard you are using, whether it is the Google stock keyboard or a third party one ......
Read more >
How To Fix Gboard Google Keyboard Disappear ... - YouTube
Subscribe to my channel https://goo.gl/Qp13QnIn this video i show you how to fix if your android phone suffers any of these problems.
Read more >
Full control with the VirtualKeyboard API - Chrome Developers
To tell the browser that you are taking care of virtual keyboard occlusions yourself, you need to first opt in to the new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found