[FIX] Autocomplete position on Android (#2106)

* [FIX] Autocomplete position on Android

* [FIX] Set selection to 0 when needed

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-05-18 15:22:01 -03:00 committed by GitHub
parent a4914d73cb
commit e8c38d6f6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -487,10 +487,20 @@ class MessageBox extends Component {
} }
setInput = (text) => { setInput = (text) => {
this.text = text;
if (this.component && this.component.setNativeProps) { 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) => { setShowSend = (showSend) => {