From 716719187de163b971b8226cc79859e315ff2ae3 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 31 May 2019 15:05:09 +0200 Subject: [PATCH] only capture enter if something was selected in completions --- src/components/views/rooms/Autocomplete.js | 4 ++++ src/components/views/rooms/MessageComposerInput.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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;