Skip to content

An opinionated toast component for React.

fix(index.tsx): ensure hotkey array is not empty before checking (#703)

Hirotomo Yamada7760223e2add
diff --git a/src/index.tsx b/src/index.tsx
index cc4dedc..fc6a3db 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -739,7 +739,7 @@ const Toaster = React.forwardRef<HTMLElement, ToasterProps>(function Toaster(pro
React.useEffect(() => {
const handleKeyDown = (event: KeyboardEvent) => {
- 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) {
setExpanded(true);