Skip to content

Commit

Permalink
fix: fix callback not executing when scope is all. (#434) (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 11, 2023
1 parent ce461c9 commit e193f9a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/hotkeys.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ function dispatch(event, element) {
if (!(key in _handlers)) return;
for (var _i = 0; _i < _handlers[key].length; _i++) {
if (event.type === 'keydown' && _handlers[key][_i].keydown || event.type === 'keyup' && _handlers[key][_i].keyup) {
if (_handlers[key][_i].key && _handlers[key][_i].scope === scope) {

This comment has been minimized.

Copy link
@YuxuanWeng

YuxuanWeng Jul 13, 2023

Contributor

能不能在这判断来修复呢?不然我系统中给用户设置快捷键的时候,会由于绑定过其他scope的事件而导致这个顺序有问题。。
if (_handlers[key][_i].key && (_handlers[key][_i].scope === scope || _handlers[key][_i].scope === 'all')) {

This comment has been minimized.

Copy link
@jaywcjlove

jaywcjlove Jul 13, 2023

Author Owner

@YuxuanWeng 会出现 #434 的 bug

This comment has been minimized.

Copy link
@jaywcjlove

jaywcjlove Jul 13, 2023

Author Owner

@YuxuanWeng 我觉得可以通过一个 options 开关来解决这个问题

if (_handlers[key][_i].key) {
var record = _handlers[key][_i];
var splitKey = record.splitKey;
var keyShortcut = record.key.split(splitKey);
Expand Down
2 changes: 1 addition & 1 deletion dist/hotkeys.common.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/hotkeys.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ function dispatch(event, element) {
if (!(key in _handlers)) return;
for (var _i = 0; _i < _handlers[key].length; _i++) {
if (event.type === 'keydown' && _handlers[key][_i].keydown || event.type === 'keyup' && _handlers[key][_i].keyup) {
if (_handlers[key][_i].key && _handlers[key][_i].scope === scope) {
if (_handlers[key][_i].key) {
var record = _handlers[key][_i];
var splitKey = record.splitKey;
var keyShortcut = record.key.split(splitKey);
Expand Down
2 changes: 1 addition & 1 deletion dist/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
if (!(key in _handlers)) return;
for (var _i = 0; _i < _handlers[key].length; _i++) {
if (event.type === 'keydown' && _handlers[key][_i].keydown || event.type === 'keyup' && _handlers[key][_i].keyup) {
if (_handlers[key][_i].key && _handlers[key][_i].scope === scope) {
if (_handlers[key][_i].key) {
var record = _handlers[key][_i];
var splitKey = record.splitKey;
var keyShortcut = record.key.split(splitKey);
Expand Down
Loading

0 comments on commit e193f9a

Please sign in to comment.