From a7edb382a722796af32e97548f0a87d41ae503e8 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Fri, 21 Mar 2025 16:46:27 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9(frontent)=20change=20selector=20to?= =?UTF-8?q?=20block=20cmd+k?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Multiple ctrl+k could open the search modal, we change the selector, now if the toolbar is displayed we don't open the search modal. --- .../features/left-panel/components/LeftPanelHeader.tsx | 10 +++++++++- src/frontend/apps/impress/src/hook/useCmdK.tsx | 6 ------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/frontend/apps/impress/src/features/left-panel/components/LeftPanelHeader.tsx b/src/frontend/apps/impress/src/features/left-panel/components/LeftPanelHeader.tsx index 80db8df3..1ef117e9 100644 --- a/src/frontend/apps/impress/src/features/left-panel/components/LeftPanelHeader.tsx +++ b/src/frontend/apps/impress/src/features/left-panel/components/LeftPanelHeader.tsx @@ -15,7 +15,15 @@ export const LeftPanelHeader = ({ children }: PropsWithChildren) => { const router = useRouter(); const searchModal = useModal(); const { authenticated } = useAuth(); - useCmdK(searchModal.open); + useCmdK(() => { + const isEditorToolbarOpen = + document.getElementsByClassName('bn-formatting-toolbar').length > 0; + if (isEditorToolbarOpen) { + return; + } + + searchModal.open(); + }); const { togglePanel } = useLeftPanelStore(); const { mutate: createDoc } = useCreateDoc({ diff --git a/src/frontend/apps/impress/src/hook/useCmdK.tsx b/src/frontend/apps/impress/src/hook/useCmdK.tsx index 457af3cd..562d8e83 100644 --- a/src/frontend/apps/impress/src/hook/useCmdK.tsx +++ b/src/frontend/apps/impress/src/hook/useCmdK.tsx @@ -6,12 +6,6 @@ export const useCmdK = (callback: () => void) => { if ((e.key === 'k' || e.key === 'K') && (e.metaKey || e.ctrlKey)) { e.preventDefault(); - const isProseMirrorFocused = - document.activeElement?.classList.contains('ProseMirror'); - if (isProseMirrorFocused) { - return; - } - callback(); } };