From 102a56e7cff2e826d544cac444ca9130e664a1a5 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 27 Jun 2017 16:27:39 -0400 Subject: [PATCH] RN-237 Re-added workaround for pressing enter on Android (#679) * Stop 'make stop-packager' from erroring when packager isn't running * RN-237 Re-added workaround for pressing enter on Android --- Makefile | 4 +++- app/components/post_textbox/post_textbox.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0304032c3..304a9dcc4 100644 --- a/Makefile +++ b/Makefile @@ -113,7 +113,9 @@ start-packager: stop-packager: @echo Stopping React Native packager server - @kill -9 `cat server.PID` && rm server.PID + @if [ -e "server.PID" ] ; then \ + kill -9 `cat server.PID` && rm server.PID; \ + fi check-ios-target: ifneq ($(ios_target), $(filter $(ios_target), dev beta release)) diff --git a/app/components/post_textbox/post_textbox.js b/app/components/post_textbox/post_textbox.js index 430c8d9a7..7154efb2e 100644 --- a/app/components/post_textbox/post_textbox.js +++ b/app/components/post_textbox/post_textbox.js @@ -217,6 +217,20 @@ class PostTextbox extends PureComponent { }); }; + handleSubmit = () => { + // Workaround for android as the multiline is not working + if (Platform.OS === 'android') { + if (this.timeout) { + clearTimeout(this.timeout); + } + this.timeout = setTimeout(() => { + let {value: msg} = this.props; + msg += '\n'; + this.handleTextChange(msg); + }, 10); + } + }; + attachAutocomplete = (c) => { this.autocomplete = c; }; @@ -453,6 +467,7 @@ class PostTextbox extends PureComponent { blurOnSubmit={false} underlineColorAndroid='transparent' style={[style.input, {height: textInputHeight}]} + onSubmitEditing={this.handleSubmit} onLayout={this.handleInputSizeChange} /> {this.canSend() &&