🩹(frontent) change selector to block cmd+k

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.
This commit is contained in:
Anthony LC
2025-03-21 16:46:27 +01:00
committed by Anthony LC
parent fb5400c26b
commit a7edb382a7
2 changed files with 9 additions and 7 deletions

View File

@@ -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({

View File

@@ -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();
}
};