saas-js / saas-ui

The React component library for startups, built with Chakra UI.
https://saas-ui.dev
MIT License
1.23k stars 118 forks source link

Bug: useHotkeys and multiple pressings with special keys will make a stuck normal hotkey #222

Closed tani-shi closed 1 month ago

tani-shi commented 2 months ago

Description

When I do pressing multiple times a some key with keeping pressing a special key (e.g. cmd + z), normal hotkey (e.g. ArrowUp, ArrowDown) will be stuck and not working.

export const appHotkeys = {
...
      undo: {
        label: 'table.undo',
        command: platformSelect({ mac: '⌘ Z' }, 'Ctrl+Z'),
      },
...
} satisfies HotkeysConfig
useHotkeys(
    [
      'ArrowUp',
      '⇧ ArrowUp',
      'ArrowDown',
      '⇧ ArrowDown',
      'ArrowLeft',
      '⇧ ArrowLeft',
      'ArrowRight',
      '⇧ ArrowRight',
    ],
    (e) => {
    // won't be fired
    },
    [...]
)

Link to Reproduction

No response

Steps to reproduce

  1. Define a hotkey with cmd+z (undo) to hotkeys.ts
  2. Implement useHotkeysShortcut for hooking undo command
  3. Implement useHotkeys for hooking ArrowUp/ArrowDown
  4. Undo multiple times with keeping pressing cmd key
  5. Press ArrowUp or ArrowDown will be not working

Saas UI Version

2.6.2

Chakra UI Version

No response

Browser

No response

Operating System

Additional Information

No response

linear[bot] commented 2 months ago

SUI-461 Bug: useHotkeys and multiple pressings with special keys will make a stuck normal hotkey

Pagebakers commented 2 months ago

Thanks for reporting, will investigate asap.

Pagebakers commented 1 month ago

Fixed in 2.8.2