Merge pull request #3047 from matrix-org/bwindels/autocomplete-enter-fix

only capture enter if something was selected in completions
This commit is contained in:
Bruno Windels 2019-05-31 13:17:35 +00:00 committed by GitHub
commit 2f98d0edb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -162,6 +162,10 @@ export default class Autocomplete extends React.Component {
}); });
} }
hasSelection(): bool {
return this.countCompletions() > 0 && this.state.selectionOffset !== 0;
}
countCompletions(): number { countCompletions(): number {
return this.state.completionList.length; return this.state.completionList.length;
} }

View file

@ -989,7 +989,7 @@ export default class MessageComposerInput extends React.Component {
return change.insertText('\n'); return change.insertText('\n');
} }
if (this.autocomplete.countCompletions() > 0) { if (this.autocomplete.hasSelection()) {
this.autocomplete.hide(); this.autocomplete.hide();
ev.preventDefault(); ev.preventDefault();
return true; return true;