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.

Content hides Input when keyboard visible (i.e. not keyboard-aware-scroll-view)

See original GitHub issue

react-native, react and native-base version

{
  "main": "node_modules/expo/AppEntry.js",
  "private": true,
  "scripts": {
    "test": "node ./node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/samples": "2.1.1",
    "@expo/vector-icons": "^6.2.1",
    "expo": "^23.0.0",
    "firebase": "^4.6.2",
    "native-base": "^2.3.3",
    "react": "16.0.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-23.0.0.tar.gz",
    "react-native-datepicker": "^1.6.0",
    "react-navigation": "^1.0.0-beta.19",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.2.0"
  },
  "devDependencies": {
    "jest-expo": "^23.0.0"
  }
}

Expected behaviour

Content advertises to replace KeyboardAwareScrollView.

  1. Auto-Scrolling should happen when I type an input on lower half of screen.
  2. It is possible to scroll manually to make the input visible.

Actual behaviour

  1. No auto-scrolling happens. Both with Asus ZenUI keyboard and Google Gboard.
  2. It’s not possible to scroll manually to make the input visible. (see below for workaround)

Wrapping the Input/Item with KeyboardAvoidingView does not work either.

Input:

image

is obscured:

image

Steps to reproduce (code snippet or screenshot)

      <Container>
        <Content>
          <Form>
             ...other <Item>s...
            <Item stackedLabel>
              <Label>Pekerjaan (lainnya)</Label>
              <Input value={this.state.userProfile.employment_other}
                onChangeText={(text) => this.setState({userProfile: {...this.state.userProfile, employment_other: text}})}/>
            </Item>
          </Form>
        </Content>
      </Container>

Tried using: <Content contentContainerStyle={{flex: 1}}> but made the content squashed.

Partial Workaround: As @samarhaider suggests (https://github.com/GeekyAnts/NativeBase/issues/534#issuecomment-344689283) it’s possible to use @Andr3wHur5t’s <KeyboardSpacer/> to allow scrolling manually when keyboard is visible. However, auto-scroll still does not occur even with KeyboardSpacer :

videotogif_2017 12 05_04 26 44

Is the bug present in both ios and android or in any one of them?

Only tested with Android 7.0. Probably related to #534, #79.

Tips

I suggest modifying the KitchenSink to add long forms to better test this behavior in the future.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

68reactions
Almajucommented, Apr 11, 2018

I made it work with https://github.com/APSL/react-native-keyboard-aware-scroll-view on Expo

You need to add this to app.json:

"androidStatusBar": {
  "backgroundColor": "#000000"
}

Then:

import React from 'react';
import { Platform, View } from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';

const Content = () => (
  <KeyboardAwareScrollView
    enableOnAndroid
    enableAutomaticScroll
    keyboardOpeningTime={0}
    extraHeight={Platform.select({ android: 200 })}
  >
    <View>
      {props.children}
    </View>
  </KeyboardAwareScrollView>
);
37reactions
allan-simoncommented, Feb 27, 2019

following this comment https://github.com/expo/expo/issues/1073#issuecomment-467782012
simply adding enableOnAndroid to Content make it works (as Content behind the hood is already a keyboaravoidingview-ish )

  <Container>
    <Content enableOnAndroid>
      <Form>
        <Item>
          <Input />
        </Item>
      </Form>
    </Content>
  </Container>
Read more comments on GitHub >

github_iconTop Results From Across the Web

KeyboardAvoidingView with ScrollView - Stack Overflow
This is what my solution would be, it works and scrolls automatically on focus input. I tried this on Expo, hope it helps....
Read more >
Using KeyboardAwareScrollView and KeyboardAvoidingView ...
This tutorial explains what KeyboardAvoidingView and KeyboardAwareScrollView are and how to use them for different purposes.
Read more >
React Native Keyboard Covering Inputs | by John Tucker
The general problem is that React Native does not automatically account for the on-screen keyboard covering up a portion of the screen. note: ......
Read more >
native base keyboardavoidingview - You.com | The AI Search ...
I use the KeyboardAvoidingView, to display the input focused, but when the KeyBoard is showing, the scrollView paddingBottom changes and overlaps the Form....
Read more >
react-native-keyboard-aware-scroll-view not working properly
I am trying to use the react-native-keyboard-aware-scroll-view so the keyboard ... visible={this.state.visible} /> <StatusBar barStyle="light-content" ...
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