🩹(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:
@@ -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({
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user