Skip to content

Commit

Permalink
unbind hotkeys with scope to allow unbinding hotkeys only
Browse files Browse the repository at this point in the history
within a scope if one has been provided (see also stimulus-use#177)
  • Loading branch information
tkoenig committed Nov 24, 2022
1 parent eb759b5 commit d832e2d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/use-hotkeys/use-hotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ export class UseHotkeys extends StimulusUse {
}

unbind = () => {
for (const hotkey in this.hotkeysOptions.hotkeys as any) {
hotkeys.unbind(hotkey)
for (const [hotkey, definition] of Object.entries(this.hotkeysOptions.hotkeys as any)) {
const options = (definition as HotkeyDefinition).options
const scope = options.scope ? options.scope : ''
hotkeys.unbind(hotkey, scope)
}
}

Expand Down

0 comments on commit d832e2d

Please sign in to comment.