diff --git a/src/components/views/rooms/Autocomplete.js b/src/components/views/rooms/Autocomplete.js index 466deeba28..9aef5433c3 100644 --- a/src/components/views/rooms/Autocomplete.js +++ b/src/components/views/rooms/Autocomplete.js @@ -162,6 +162,10 @@ export default class Autocomplete extends React.Component { }); } + hasSelection(): bool { + return this.countCompletions() > 0 && this.state.selectionOffset !== 0; + } + countCompletions(): number { return this.state.completionList.length; } diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index e1a7f559f8..a525fcb874 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -989,7 +989,7 @@ export default class MessageComposerInput extends React.Component { return change.insertText('\n'); } - if (this.autocomplete.countCompletions() > 0) { + if (this.autocomplete.hasSelection()) { this.autocomplete.hide(); ev.preventDefault(); return true;