mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-16 09:10:33 +03:00
Change all keyup events to keydown (#935)
For a few reasons: - event.preventDefault() for the Enter key (to stop it from submitting the form when you select an item) is only effective if it's a keydown event. - Using keydown for up/down navigation means you can hold them down to rapidly scroll through a lot of items. - Keydown events make the UX feel more responsive, and is consistent with how most apps/operating systems handle key presses.
This commit is contained in:
@@ -852,16 +852,10 @@
|
||||
case 9:
|
||||
// tab
|
||||
return this.onTab();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Search 'input' KeyBoardEvent handler.
|
||||
* @param e {KeyboardEvent}
|
||||
* @return {Function}
|
||||
*/
|
||||
onSearchKeyUp (e) {
|
||||
switch (e.keyCode) {
|
||||
case 13:
|
||||
// enter.prevent
|
||||
e.preventDefault();
|
||||
return this.typeAheadSelect();
|
||||
case 27:
|
||||
// esc
|
||||
return this.onEscape();
|
||||
@@ -873,10 +867,6 @@
|
||||
// down.prevent
|
||||
e.preventDefault();
|
||||
return this.typeAheadDown();
|
||||
case 13:
|
||||
// enter.prevent
|
||||
e.preventDefault();
|
||||
return this.typeAheadSelect();
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -955,7 +945,6 @@
|
||||
},
|
||||
events: {
|
||||
'keydown': this.onSearchKeyDown,
|
||||
'keyup': this.onSearchKeyUp,
|
||||
'blur': this.onSearchBlur,
|
||||
'focus': this.onSearchFocus,
|
||||
'input': (e) => this.search = e.target.value
|
||||
|
||||
Reference in New Issue
Block a user