Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3047 from matrix-org/bwindels/autocomplete-enter-fix
Browse files Browse the repository at this point in the history
only capture enter if something was selected in completions
  • Loading branch information
bwindels authored May 31, 2019
2 parents 512c9b2 + 7167191 commit 2f98d0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/views/rooms/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/rooms/MessageComposerInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2f98d0e

Please sign in to comment.