feat: 快速切换增加esc快速关闭

pull/13/head
moonrailgun 3 years ago
parent 1a98d52cb0
commit d13d773704

@ -5,7 +5,12 @@ import { t } from 'tailchat-shared';
import { PortalAdd, PortalRemove } from '../Portal';
import clsx from 'clsx';
import { useGlobalKeyDown } from '@/hooks/useGlobalKeyDown';
import { isArrowDown, isArrowUp, isEnterHotkey } from '@/utils/hot-key';
import {
isArrowDown,
isArrowUp,
isEnterHotkey,
isEscHotkey,
} from '@/utils/hot-key';
import { useQuickSwitcherActionContext } from './useQuickSwitcherActionContext';
import { useQuickSwitcherFilteredActions } from './useQuickSwitcherFilteredActions';
@ -42,6 +47,8 @@ const QuickSwitcher: React.FC = React.memo(() => {
typeof selectedAction.action === 'function' &&
selectedAction.action(actionContext);
handleClose();
} else if (isEscHotkey(e)) {
handleClose();
}
});

@ -2,6 +2,8 @@ import { isHotkey } from 'is-hotkey';
export const isEnterHotkey = isHotkey('enter');
export const isEscHotkey = isHotkey('esc');
export const isQuickSwitcher = isHotkey('mod+k');
export const isArrowUp = isHotkey('up');

Loading…
Cancel
Save