forked from 0x2620/oxjs
fix a bug where space key wouldn't register while autocomplete menu was open
This commit is contained in:
parent
0ebd4efc72
commit
6e0bafed88
3 changed files with 42 additions and 27 deletions
|
|
@ -60,20 +60,26 @@
|
|||
key = keyNames.join('_');
|
||||
if (focused !== null) {
|
||||
Ox.UI.elements[focused].triggerEvent('key_' + key);
|
||||
// prevent Chrome fromor scrolling
|
||||
// fixme: backspace -> history.back, blocking it doesn't work
|
||||
// when the autocomplete menu of an input element has focus
|
||||
// prevent Chrome from scrolling, or going back in history
|
||||
if (
|
||||
[
|
||||
'down', 'left', 'right', 'space', 'up'
|
||||
].indexOf(keyBasename) > -1 &&
|
||||
!Ox.UI.elements[focused].hasClass('OxInput')
|
||||
'backspace', 'down', 'left', 'right', 'space', 'up'
|
||||
].indexOf(key) > -1 &&
|
||||
!Ox.UI.elements[focused].hasClass('OxInput') &&
|
||||
!Ox.UI.elements[focused].hasClass('OxAutocompleteMenu')
|
||||
) {
|
||||
ret = false;
|
||||
}
|
||||
// prevent cursor in input field from moving to start or end
|
||||
if (
|
||||
['down', 'up'].indexOf(key) > -1 &&
|
||||
Ox.UI.elements[focused].hasClass('OxAutocompleteMenu')
|
||||
) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (/^[\w\d](\.numpad)?$|space/.test(key)) {
|
||||
if (/^[\w\d](\.numpad)?$|^space$/.test(key)) {
|
||||
// don't register leading spaces or trailing double spaces
|
||||
if (!(keyName == 'space' && (buffer == '' || / $/.test(buffer)))) {
|
||||
buffer += keyName == 'space' ? ' ' : keyBasename;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue