This commit is contained in:
梁灏 2019-10-15 11:11:44 +08:00
parent c3c9b8c913
commit 62211805cb

View file

@ -590,31 +590,32 @@
this.filterQueryChange = false; this.filterQueryChange = false;
}, },
handleKeydown (e) { handleKeydown (e) {
if (e.key === 'Backspace'){ const key = e.key || e.code;
if (key === 'Backspace'){
return; // so we don't call preventDefault return; // so we don't call preventDefault
} }
if (this.visible) { if (this.visible) {
e.preventDefault(); e.preventDefault();
if (e.key === 'Tab'){ if (key === 'Tab'){
e.stopPropagation(); e.stopPropagation();
} }
// Esc slide-up // Esc slide-up
if (e.key === 'Escape') { if (key === 'Escape') {
e.stopPropagation(); e.stopPropagation();
this.hideMenu(); this.hideMenu();
} }
// next // next
if (e.key === 'ArrowUp') { if (key === 'ArrowUp') {
this.navigateOptions(-1); this.navigateOptions(-1);
} }
// prev // prev
if (e.key === 'ArrowDown') { if (key === 'ArrowDown') {
this.navigateOptions(1); this.navigateOptions(1);
} }
// enter // enter
if (e.key === 'Enter') { if (key === 'Enter') {
if (this.focusIndex === -1) return this.hideMenu(); if (this.focusIndex === -1) return this.hideMenu();
const optionComponent = this.flatOptions[this.focusIndex]; const optionComponent = this.flatOptions[this.focusIndex];