Skip to content

When hotKey is set to an empty array, keyboard operations become erratic. #701

@hirotomoyamada

Description

@hirotomoyamada

It's likely caused by the every method inside useEffect.

React.useEffect(() => {
  const handleKeyDown = (event: KeyboardEvent) => {
    const isHotkeyPressed = hotkey.every((key) => (event as any)[key] || event.code === key);

    if (isHotkeyPressed) {
      setExpanded(true);
      listRef.current?.focus();
    }

    if (
      event.code === 'Escape' &&
      (document.activeElement === listRef.current || listRef.current?.contains(document.activeElement))
    ) {
      setExpanded(false);
    }
  };
  document.addEventListener('keydown', handleKeyDown);

  return () => document.removeEventListener('keydown', handleKeyDown);
}, [hotkey]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions