keyboard shortcut for closing

This commit is contained in:
Nate Kelley 2025-03-12 12:34:21 -06:00
parent 2788f7e675
commit bffe175bed
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 13 additions and 2 deletions

View File

@ -19,7 +19,7 @@ KeyboardShortcutPill.displayName = 'KeyboardShortcutPill';
const TooltipShortcut: React.FC<{ shortcut: string }> = ({ shortcut }) => {
return (
<div className="border-border bg-background text2xs pointer-events-none relative flex h-5 w-[1.375rem] items-center justify-center rounded border-[0.5px] leading-none shadow">
<div className="border-border bg-background text2xs pointer-events-none relative flex h-5 w-[1.375rem] items-center justify-center rounded border-[0.5px] px-[1.5px] leading-none shadow">
{shortcut}
</div>
);

View File

@ -4,9 +4,18 @@ import { Button } from '@/components/ui/buttons';
import { Xmark } from '@/components/ui/icons';
import { useChatLayoutContextSelector } from '@/layouts/ChatLayout';
import { cn } from '@/lib/classMerge';
import { AppTooltip } from '@/components/ui/tooltip';
import { useHotkeys } from 'react-hotkeys-hook';
export const MetricEditControllerHeader: React.FC = React.memo(() => {
const closeSecondaryView = useChatLayoutContextSelector((x) => x.closeSecondaryView);
const selectedFileViewSecondary = useChatLayoutContextSelector(
(x) => x.selectedFileViewSecondary
);
useHotkeys('esc', () => closeSecondaryView(), {
enabled: !!selectedFileViewSecondary
});
return (
<div
@ -16,7 +25,9 @@ export const MetricEditControllerHeader: React.FC = React.memo(() => {
'px-4 py-2.5'
)}>
<Text>Edit chart</Text>
<Button onClick={closeSecondaryView} variant="ghost" prefix={<Xmark />} />
<AppTooltip title="Close" shortcuts={['esc']}>
<Button onClick={closeSecondaryView} variant="ghost" prefix={<Xmark />} />
</AppTooltip>
</div>
);
});