Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

Merge branch 'master' into fix/update-search-ui

JimmFly10c082b8e3e9
diff --cc packages/app/src/components/quick-search/index.tsx
index 39a9ec0366,15659e5558..f1d2c094b9
--- a/packages/app/src/components/quick-search/index.tsx
+++ b/packages/app/src/components/quick-search/index.tsx
@@@ -30,9 -30,11 +30,13 @@@ export const QuickSearch = ({ open, onC
const [publishWorkspaceName, setPublishWorkspaceName] = useState('');
const [showCreatePage, setShowCreatePage] = useState(true);
const { triggerQuickSearchModal } = useModal();
-
+ const isPublicAndNoQuery = () => {
+ return isPublic && query.length === 0;
+ };
+ const handleClose = () => {
+ setQuery('');
+ onClose();
+ };
// Add ‘⌘+K’ shortcut keys as switches
useEffect(() => {
const down = (e: KeyboardEvent) => {
@@@ -42,7 -45,7 +47,10 @@@
triggerQuickSearchModal(false);
return;
}
-- if (selection?.isCollapsed) {
++ if (
++ selection?.isCollapsed &&
++ router.pathname.startsWith('/404') !== true
++ ) {
triggerQuickSearchModal(!open);
}
}
@@@ -50,18 -53,15 +58,18 @@@
document.addEventListener('keydown', down, { capture: true });
return () =>
document.removeEventListener('keydown', down, { capture: true });
-- }, [open, triggerQuickSearchModal]);
++ }, [open, router.pathname, triggerQuickSearchModal]);
useEffect(() => {
++ if (router.pathname.startsWith('/404')) {
++ return handleClose();
++ }
if (router.pathname.startsWith('/public-workspace')) {
return setIsPublic(true);
} else {
return setIsPublic(false);
}
-- }, [router]);
++ }, [handleClose, router]);
return (
<Modal
@@@ -102,47 -102,38 +110,42 @@@
/>
<StyledShortcut>{isMac() ? '⌘ + K' : 'Ctrl + K'}</StyledShortcut>
</StyledModalHeader>
- <>
- <StyledModalDivider
- <StyledModalDivider />
++ <StyledModalDivider
++ style={{ display: isPublicAndNoQuery() ? 'none' : '' }}
++ />
+ <Command.List>
- <StyledContent>
++ <StyledContent
+ style={{ display: isPublicAndNoQuery() ? 'none' : '' }}
- />
- <Command.List>
- <StyledContent
- style={{ display: isPublicAndNoQuery() ? 'none' : '' }}
- >
- {!isPublic ? (
- <Results
- query={query}
- loading={loading}
- setLoading={setLoading}
- setShowCreatePage={setShowCreatePage}
- />
- ) : (
- <PublishedResults
- query={query}
- loading={loading}
- setLoading={setLoading}
- onClose={onClose}
- setPublishWorkspaceName={setPublishWorkspaceName}
- />
- )}
- </StyledContent>
++ >
{!isPublic ? (
- showCreatePage ? (
- <>
- <StyledModalDivider />
- <StyledModalFooter>
- <Footer query={query} />
- </StyledModalFooter>
- </>
- ) : (
- <></>
- )
+ <Results
+ query={query}
+ loading={loading}
+ setLoading={setLoading}
+ onClose={handleClose}
+ setShowCreatePage={setShowCreatePage}
+ />
) : (
- <></>
+ <PublishedResults
+ query={query}
+ loading={loading}
+ setLoading={setLoading}
+ onClose={handleClose}
+ setPublishWorkspaceName={setPublishWorkspaceName}
+ />
)}
- </Command.List>
- </>
+ </StyledContent>
+ {!isPublic ? (
+ showCreatePage ? (
+ <>
+ <StyledModalDivider />
+ <StyledModalFooter>
+ <Footer query={query} onClose={handleClose} />
+ </StyledModalFooter>
+ </>
+ ) : null
+ ) : null}
+ </Command.List>
</Command>
</ModalWrapper>
</Modal>