React-native: iOS Keyboard displays over TextInput field preventing user from seeing it.

Created on 28 Mar 2015  路  13Comments  路  Source: facebook/react-native

When a field is displayed in lower part of screen and user taps on it to enter text, the keyboard displays on top of the field forcing the user to scroll to see the field again. The correct behavior should be to slide the underlying window up when the keyboard is being displayed so it doesn't cover the input field.

Replicate bug: Using the UIExplorer text input demo screen, try entering text into a TextField that is on bottom of screen. Keyboard displays on top of TextField and hides the text field from view.

Locked

Most helpful comment

KeyboardAvoidingView does not work...
https://github.com/facebook/react-native/issues/8855

All 13 comments

:+1: I've also been trying to find a work around for this in the meantime (i.e. something along the lines of onFocus={this._slideViewUpToShowInputElement(refName)}

:+1:

Could you give us an example @erikthedeveloper , I can't get this work :( Thanks!

:+1:

I can't do work
the error message is not a function

Ahh, good call @erikthedeveloper. Hopefully this behavior will be baked in soon!

@stirman how do you do , can show me show source

If the solution that @wangzhe1995 linked to does not work for anybody, ping me and I'll re-open the issue! :smile:

It would be awesome to see a component/example of a messaging view where the keyboard slides up with the input field. :+1:

As of React Native 0.29 you can use React Native's <KeyboardAvoidingView/>

https://github.com/facebook/react-native/commit/8b78846a9501ef9c5ce9d1e18ee104bfae76af2e

KeyboardAvoidingView does not work...
https://github.com/facebook/react-native/issues/8855

Hi All,
i just resolve this issue with alternative solution, by using the animation, Hope this will help

import { Animated, Keyboard} from 'react-native';

constructor(props) {
super(props);

//For the keyboard
this.keyboardHeight = new Animated.Value(0);

}

//For key board
componentWillMount () {
console.log("Keyboard componentWillMount")
this.keyboardWillShowSub = Keyboard.addListener('keyboardWillShow', this.keyboardWillShow);
this.keyboardWillHideSub = Keyboard.addListener('keyboardWillHide', this.keyboardWillHide);
}

componentWillUnmount() {
console.log("Keyboard componentWillUnmount")
this.keyboardWillShowSub.remove();
this.keyboardWillHideSub.remove();
}

keyboardWillShow = (event) => {
console.log("keyboardWillShow")
Animated.parallel([
Animated.timing(this.keyboardHeight, {
duration: event.duration,
toValue: event.endCoordinates.height,
})
]).start();
};

keyboardWillHide = (event) => {
console.log("keyboardWillHide")
Animated.parallel([
Animated.timing(this.keyboardHeight, {
duration: event.duration,
toValue: 0,
})
]).start();
};
render() {


}

Was this page helpful?
0 / 5 - 0 ratings