mirror of https://github.com/buster-so/buster.git
keyboard shortcut for closing
This commit is contained in:
parent
2788f7e675
commit
bffe175bed
|
@ -19,7 +19,7 @@ KeyboardShortcutPill.displayName = 'KeyboardShortcutPill';
|
||||||
|
|
||||||
const TooltipShortcut: React.FC<{ shortcut: string }> = ({ shortcut }) => {
|
const TooltipShortcut: React.FC<{ shortcut: string }> = ({ shortcut }) => {
|
||||||
return (
|
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}
|
{shortcut}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,9 +4,18 @@ import { Button } from '@/components/ui/buttons';
|
||||||
import { Xmark } from '@/components/ui/icons';
|
import { Xmark } from '@/components/ui/icons';
|
||||||
import { useChatLayoutContextSelector } from '@/layouts/ChatLayout';
|
import { useChatLayoutContextSelector } from '@/layouts/ChatLayout';
|
||||||
import { cn } from '@/lib/classMerge';
|
import { cn } from '@/lib/classMerge';
|
||||||
|
import { AppTooltip } from '@/components/ui/tooltip';
|
||||||
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
|
|
||||||
export const MetricEditControllerHeader: React.FC = React.memo(() => {
|
export const MetricEditControllerHeader: React.FC = React.memo(() => {
|
||||||
const closeSecondaryView = useChatLayoutContextSelector((x) => x.closeSecondaryView);
|
const closeSecondaryView = useChatLayoutContextSelector((x) => x.closeSecondaryView);
|
||||||
|
const selectedFileViewSecondary = useChatLayoutContextSelector(
|
||||||
|
(x) => x.selectedFileViewSecondary
|
||||||
|
);
|
||||||
|
|
||||||
|
useHotkeys('esc', () => closeSecondaryView(), {
|
||||||
|
enabled: !!selectedFileViewSecondary
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
@ -16,7 +25,9 @@ export const MetricEditControllerHeader: React.FC = React.memo(() => {
|
||||||
'px-4 py-2.5'
|
'px-4 py-2.5'
|
||||||
)}>
|
)}>
|
||||||
<Text>Edit chart</Text>
|
<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>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue