Disable quicksearch on 404 page

This commit is contained in:
JimmFly
2023-02-07 13:14:19 +08:00
parent 10c082b8e3
commit e559ae3490

View File

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