From e8c38d6f6f69ae396a4aae6e37336617da739a6d Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 18 May 2020 15:22:01 -0300 Subject: [PATCH] [FIX] Autocomplete position on Android (#2106) * [FIX] Autocomplete position on Android * [FIX] Set selection to 0 when needed Co-authored-by: Diego Mello --- app/containers/MessageBox/index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/containers/MessageBox/index.js b/app/containers/MessageBox/index.js index 39e29dbc..7ca8db2c 100644 --- a/app/containers/MessageBox/index.js +++ b/app/containers/MessageBox/index.js @@ -487,10 +487,20 @@ class MessageBox extends Component { } setInput = (text) => { - this.text = text; if (this.component && this.component.setNativeProps) { - this.component.setNativeProps({ text }); + const props = { text }; + + if (isAndroid) { + const diff = text.length - this.text?.length; + const selection = this.component?.lastNativeSelection; + const start = selection?.start + diff >= 0 ? selection?.start + diff : text.length; + const end = selection?.end + diff >= 0 ? selection?.start + diff : text.length; + props.selection = { start, end }; + } + + this.component.setNativeProps(props); } + this.text = text; } setShowSend = (showSend) => {