Hotkey for creating environment when dialog open

This commit is contained in:
Gregory Schier
2025-10-26 12:10:41 -07:00
parent 3f5b5a397c
commit b2766509e3
3 changed files with 12 additions and 4 deletions

View File

@@ -21,6 +21,7 @@ export type ButtonProps = Omit<HTMLAttributes<HTMLButtonElement>, 'color' | 'onC
leftSlot?: ReactNode;
rightSlot?: ReactNode;
hotkeyAction?: HotkeyAction;
hotkeyPriority?: number;
};
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
@@ -39,6 +40,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button
rightSlot,
disabled,
hotkeyAction,
hotkeyPriority,
title,
onClick,
...props
@@ -94,9 +96,13 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button
() => buttonRef.current,
);
useHotKey(hotkeyAction ?? null, () => {
buttonRef.current?.click();
});
useHotKey(
hotkeyAction ?? null,
() => {
buttonRef.current?.click();
},
{ priority: hotkeyPriority },
);
return (
<button