From bffe175bed4c600ddce491813d327e3ad090598c Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Wed, 12 Mar 2025 12:34:21 -0600 Subject: [PATCH] keyboard shortcut for closing --- .../components/ui/pills/KeyboardShortcutPills.tsx | 2 +- .../MetricEditControllerHeader.tsx | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/web/src/components/ui/pills/KeyboardShortcutPills.tsx b/web/src/components/ui/pills/KeyboardShortcutPills.tsx index 2fc8bc719..f78846c00 100644 --- a/web/src/components/ui/pills/KeyboardShortcutPills.tsx +++ b/web/src/components/ui/pills/KeyboardShortcutPills.tsx @@ -19,7 +19,7 @@ KeyboardShortcutPill.displayName = 'KeyboardShortcutPill'; const TooltipShortcut: React.FC<{ shortcut: string }> = ({ shortcut }) => { return ( -
+
{shortcut}
); diff --git a/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricEditControllerHeader.tsx b/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricEditControllerHeader.tsx index 9c0249491..23ea15b9d 100644 --- a/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricEditControllerHeader.tsx +++ b/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricEditControllerHeader.tsx @@ -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 (
{ 'px-4 py-2.5' )}> Edit chart -
); });