KeyboardAvoidingView has no effect on multiline TextInput
See original GitHub issueKeyboardAvoidingView only works with single-line TextInputs. When the multiline
prop is set, KeyboardAvoidingView does not shift the TextInput at all.
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
Environment: OS: macOS Sierra 10.12.6 Node: 7.0.0 npm: 3.10.8 Watchman: 4.7.0 Xcode: 9.1
Packages: (wanted => installed) react-native: 0.49.3 react: 16.0.0-beta.5
Target Platform: iOS (10.3)
Steps to Reproduce
- Use a
<TextInput>
component withmultiline
prop set. - Wrap this in a ScrollView
- Wrap that in a KeyboardAvoidingView.
Expected Behavior
Multiline TextInput should scroll above the soft keyboard.
Actual Behavior
Soft keyboard covers multiline TextInput.
Reproducible Demo
import React, { Component } from 'react';
import { Text, TextInput, View, ScrollView, KeyboardAvoidingView, Keyboard} from 'react-native';
...
render() {
return (
<KeyboardAvoidingView style={{flex:1}} behavior="padding" keyboardVerticalOffset={64}>
<ScrollView keyboardShouldPersistTaps={'handled'}>
<View style={{padding: 12}}>
// various content to fill the page
<Text style={{fontSize: 20, padding: 40}}>MESSAGE 1</Text>
<Text style={{fontSize: 20, padding: 40}}>MESSAGE 2</Text>
<Text style={{fontSize: 20, padding: 40}}>MESSAGE 3</Text>
<Text style={{fontSize: 20, padding: 40}}>MESSAGE 4</Text>
<Text style={{fontSize: 20, padding: 40}}>MESSAGE 5</Text>
<Text style={{fontSize: 20, padding: 40}}>MESSAGE 6</Text>
<Text style={{fontSize: 20, padding: 40}}>MESSAGE 7</Text>
<Text style={{fontSize: 20, padding: 40}}>MESSAGE 8</Text>
<Text style={{fontSize: 20, padding: 40}}>MESSAGE 9</Text>
<Text style={{fontSize: 20, padding: 40}}>MESSAGE 10</Text>
</View>
<TextInput
style={{padding: 4}}
multiline={true}
placeholder={'Type something here...'}
onChangeText={this.updateMessage}
value={this.state.message}
/>
</ScrollView>
</KeyboardAvoidingView>
);
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:119
- Comments:82 (4 by maintainers)
Top Results From Across the Web
React native textinput multiline is not being pushed up by ...
I had a height set on the TextInput. I removed the height and the KeyboardAvoidingView is working now but it only moves half...
Read more >How to do multiple multiline textinputs that don't hide behind ...
I've had to resort to react native's `keyboardavoidingview` , which ... It gets called every time a new line gets added to a...
Read more >TextInput - React Native
A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, such as auto-correction, ...
Read more >TextInput - React Native Archive
Determines the types of data converted to clickable URLs in the text input. Only valid if multiline={true} and editable={false} . By default no...
Read more >@kazzkiq/react-native-input-scroll-view - npm package | Snyk
Perfect TextInput ScrollView For more information about how to use this ... we didn't find any pull request activity or change in issues...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you want to KeyboardAvoidingView works fine with multiline TextInput, please setting the scrollEnabled prop of TextInput to false. It works for me.
KeyboardAvoidingView works fine with multiline TextInput because i am using them myself. Initially they would not work for me. To solve my problem i removed the height on the TextInput and set the behavior to “padding”. The “flex: 1” you have on the KeyboardAvoidingView might be the problem i think or its the scrollview. But KeyboardAvoidingView definitely works fine with multiline.