mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 22:37:04 +08:00
Disable quicksearch on 404 page
This commit is contained in:
@@ -39,6 +39,10 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
|||||||
};
|
};
|
||||||
// Add ‘⌘+K’ shortcut keys as switches
|
// Add ‘⌘+K’ shortcut keys as switches
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (router.pathname.startsWith('/404')) {
|
||||||
|
triggerQuickSearchModal(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const down = (e: KeyboardEvent) => {
|
const down = (e: KeyboardEvent) => {
|
||||||
if ((e.key === 'k' && e.metaKey) || (e.key === 'k' && e.ctrlKey)) {
|
if ((e.key === 'k' && e.metaKey) || (e.key === 'k' && e.ctrlKey)) {
|
||||||
const selection = window.getSelection();
|
const selection = window.getSelection();
|
||||||
@@ -47,10 +51,7 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
|||||||
triggerQuickSearchModal(false);
|
triggerQuickSearchModal(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (
|
if (selection?.isCollapsed) {
|
||||||
selection?.isCollapsed &&
|
|
||||||
router.pathname.startsWith('/404') !== true
|
|
||||||
) {
|
|
||||||
triggerQuickSearchModal(!open);
|
triggerQuickSearchModal(!open);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,15 +62,12 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
|||||||
}, [open, router.pathname, triggerQuickSearchModal]);
|
}, [open, router.pathname, triggerQuickSearchModal]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (router.pathname.startsWith('/404')) {
|
|
||||||
return handleClose();
|
|
||||||
}
|
|
||||||
if (router.pathname.startsWith('/public-workspace')) {
|
if (router.pathname.startsWith('/public-workspace')) {
|
||||||
return setIsPublic(true);
|
return setIsPublic(true);
|
||||||
} else {
|
} else {
|
||||||
return setIsPublic(false);
|
return setIsPublic(false);
|
||||||
}
|
}
|
||||||
}, [handleClose, router]);
|
}, [router]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
|||||||
Reference in New Issue
Block a user