fix: downkeys order error in multi listeners (#433)

Co-authored-by: Weng Yuxuan <yuxuan.weng@dealbridge.tech>
pull/437/head
Blue Daydreaming 2 years ago committed by GitHub
parent c6b7e25c16
commit 8b8d7d968a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -300,7 +300,7 @@ function dispatch(event, element) {
(event.type === 'keydown' && _handlers[key][i].keydown)
|| (event.type === 'keyup' && _handlers[key][i].keyup)
) {
if (_handlers[key][i].key) {
if (_handlers[key][i].key && _handlers[key][i].scope === scope) {
const record = _handlers[key][i];
const { splitKey } = record;
const keyShortcut = record.key.split(splitKey);
@ -308,7 +308,7 @@ function dispatch(event, element) {
for (let a = 0; a < keyShortcut.length; a++) {
_downKeysCurrent.push(code(keyShortcut[a]));
}
if (_downKeysCurrent.sort().join('') === _downKeys.sort().join('')) {
if (_downKeysCurrent.sort().join('') === _downKeys.slice().sort().join('')) {
// 找到处理内容
eventHandler(event, record, scope, element);
}

Loading…
Cancel
Save