Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: fix search in topic returns no results

ammarahm-edfb7b306bc5f6
diff --git a/apps/web/src/navigation/routes.jsx b/apps/web/src/navigation/routes.jsx
index 3fa57060b..ae6d5ee48 100644
--- a/apps/web/src/navigation/routes.jsx
+++ b/apps/web/src/navigation/routes.jsx
@@ -89,7 +89,7 @@ const routes = {
});
return {
key: "notebook",
- type: "notebook",
+ type: "notes",
title: topic.title,
component: <Topics />,
buttons: {
diff --git a/apps/web/src/views/search.jsx b/apps/web/src/views/search.jsx
index 30976d6ba..7aaefa637 100644
--- a/apps/web/src/views/search.jsx
+++ b/apps/web/src/views/search.jsx
@@ -74,14 +74,17 @@ function Search({ type }) {
const onSearch = useCallback(
async (query) => {
- if (!query) return;
+ if (!query) {
+ setResults([]);
+ return;
+ }
cachedQuery.current = query;
const [lookupType, items] = await typeToItems(type, context);
- setResults([]);
if (items.length <= 0) {
showToast("error", `There are no items to search in.`);
+ setResults([]);
return;
}
setSearchState({ isSearching: true, totalItems: items.length });
@@ -155,7 +158,7 @@ function Search({ type }) {
Searching {title}
</Text>
<SearchBox onSearch={onSearch} />
- {searchState.isSearching ? (
+ {searchState.isSearching && results?.length === 0 ? (
<Flex
sx={{
flex: "1",