Skip to content

Commit

Permalink
fix: downkeys order error in multi listeners (#433)
Browse files Browse the repository at this point in the history
Co-authored-by: Weng Yuxuan <yuxuan.weng@dealbridge.tech>
  • Loading branch information
YuxuanWeng and Weng Yuxuan committed Jun 25, 2023
1 parent c6b7e25 commit 8b8d7d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,15 @@ 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);
const _downKeysCurrent = []; // 记录当前按键键值
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);
}
Expand Down

0 comments on commit 8b8d7d9

Please sign in to comment.