Skip to content

Commit

Permalink
fix: wrong focus when hotkey is an empty array (#2491)
Browse files Browse the repository at this point in the history
Co-authored-by: Chance Strickland <hi@chance.dev>
  • Loading branch information
m-shaka and chaance authored Sep 26, 2024
1 parent 107663b commit 6ac3863
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/react/toast/src/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ const ToastViewport = React.forwardRef<ToastViewportElement, ToastViewportProps>
const handleKeyDown = (event: KeyboardEvent) => {
// we use `event.code` as it is consistent regardless of meta keys that were pressed.
// for example, `event.key` for `Control+Alt+t` is `†` and `t !== †`
const isHotkeyPressed = hotkey.every((key) => (event as any)[key] || event.code === key);
const isHotkeyPressed =
hotkey.length !== 0 && hotkey.every((key) => (event as any)[key] || event.code === key);
if (isHotkeyPressed) ref.current?.focus();
};
document.addEventListener('keydown', handleKeyDown);
Expand Down

0 comments on commit 6ac3863

Please sign in to comment.