Merge pull request #2966 from npny/npny/autocomplete-arrow-keys

Allow arrow keys navigation in autocomplete list
This commit is contained in:
Bruno Windels 2019-06-13 15:38:36 +00:00 committed by GitHub
commit 48f5cf1523
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 60 deletions

View file

@ -43,17 +43,13 @@ export default class AutocompleteWrapperModel {
async onTab(e) {
const acComponent = this._getAutocompleterComponent();
if (acComponent.state.completionList.length === 0) {
if (acComponent.countCompletions() === 0) {
// Force completions to show for the text currently entered
await acComponent.forceComplete();
// Select the first item by moving "down"
await acComponent.onDownArrow();
await acComponent.moveSelection(+1);
} else {
if (e.shiftKey) {
await acComponent.onUpArrow();
} else {
await acComponent.onDownArrow();
}
await acComponent.moveSelection(e.shiftKey ? -1 : +1);
}
this._updateCallback({
close: true,
@ -61,11 +57,11 @@ export default class AutocompleteWrapperModel {
}
onUpArrow() {
this._getAutocompleterComponent().onUpArrow();
this._getAutocompleterComponent().moveSelection(-1);
}
onDownArrow() {
this._getAutocompleterComponent().onDownArrow();
this._getAutocompleterComponent().moveSelection(+1);
}
onPartUpdate(part, offset) {