From 1641d3886312644e222248af1f2cfd2ad8ac9d47 Mon Sep 17 00:00:00 2001 From: Chris Duarte Date: Tue, 24 Oct 2017 15:43:51 -0700 Subject: [PATCH] Fix android predictive text prepend issue (#1056) --- app/components/post_textbox/post_textbox.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/components/post_textbox/post_textbox.js b/app/components/post_textbox/post_textbox.js index 04358f15b..c845c08c9 100644 --- a/app/components/post_textbox/post_textbox.js +++ b/app/components/post_textbox/post_textbox.js @@ -63,7 +63,8 @@ class PostTextbox extends PureComponent { state = { contentHeight: INITIAL_HEIGHT, - inputWidth: null + inputWidth: null, + keyboardType: 'default' }; componentDidMount() { @@ -188,9 +189,19 @@ class PostTextbox extends PureComponent { } // Shrink the input textbox since the layout events lag slightly - this.setState({ + const nextState = { contentHeight: INITIAL_HEIGHT - }); + }; + + // Fixes the issue where Android predictive text would prepend suggestions to the post draft when messages + // are typed successively without blurring the input + let callback; + if (Platform.OS === 'android') { + nextState.keyboardType = 'email-address'; + callback = () => this.setState({keyboardType: 'default'}); + } + + this.setState(nextState, callback); }; handleUploadFiles = (images) => { @@ -381,6 +392,7 @@ class PostTextbox extends PureComponent { style={[style.input, {height: textInputHeight}]} onSubmitEditing={this.handleSubmit} onLayout={this.handleInputSizeChange} + keyboardType={this.state.keyboardType} /> {this.renderSendButton()}