diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-12-20 10:43:21 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2025-12-20 10:43:21 +0000 |
| commit | 92e352f3f6b5e3be29667aad29a88769f1483564 (patch) | |
| tree | e50ecdce67f5538608b7a717a77fd2ad5df1cea0 | |
| parent | e842c5a7ac3f12af2fcd82eaa06914041647756e (diff) | |
| download | karakeep-92e352f3f6b5e3be29667aad29a88769f1483564.tar.zst | |
fix: only trigger search autocomplete on first search char
| -rw-r--r-- | apps/web/components/dashboard/search/useSearchAutocomplete.ts | 9 | ||||
| -rw-r--r-- | packages/shared-react/hooks/tags.ts | 2 |
2 files changed, 9 insertions, 2 deletions
diff --git a/apps/web/components/dashboard/search/useSearchAutocomplete.ts b/apps/web/components/dashboard/search/useSearchAutocomplete.ts index ba55d51f..7ddfa39a 100644 --- a/apps/web/components/dashboard/search/useSearchAutocomplete.ts +++ b/apps/web/components/dashboard/search/useSearchAutocomplete.ts @@ -263,6 +263,7 @@ const useTagSuggestions = ( const { data: tagResults } = useTagAutocomplete({ nameContains: debouncedTagSearchTerm, select: (data) => data.tags, + enabled: parsed.activeToken.length > 0, }); const tagSuggestions = useMemo<AutocompleteSuggestionItem[]>(() => { @@ -299,7 +300,9 @@ const useFeedSuggestions = ( : ""; const feedSearchTerm = stripSurroundingQuotes(feedSearchTermRaw); const normalizedFeedSearchTerm = feedSearchTerm.toLowerCase(); - const { data: feedResults } = api.feeds.list.useQuery(); + const { data: feedResults } = api.feeds.list.useQuery(undefined, { + enabled: parsed.activeToken.length > 0, + }); const feedSuggestions = useMemo<AutocompleteSuggestionItem[]>(() => { if (!shouldSuggestFeeds) { @@ -349,7 +352,9 @@ const useListSuggestions = ( : ""; const listSearchTerm = stripSurroundingQuotes(listSearchTermRaw); const normalizedListSearchTerm = listSearchTerm.toLowerCase(); - const { data: listResults } = useBookmarkLists(); + const { data: listResults } = useBookmarkLists(undefined, { + enabled: parsed.activeToken.length > 0, + }); const listSuggestions = useMemo<AutocompleteSuggestionItem[]>(() => { if (!shouldSuggestLists) { diff --git a/packages/shared-react/hooks/tags.ts b/packages/shared-react/hooks/tags.ts index 617c6933..e1e7416f 100644 --- a/packages/shared-react/hooks/tags.ts +++ b/packages/shared-react/hooks/tags.ts @@ -20,6 +20,7 @@ export function usePaginatedSearchTags( export function useTagAutocomplete<T>(opts: { nameContains: string; select?: (tags: ZTagListResponse) => T; + enabled?: boolean; }) { return api.tags.list.useQuery( { @@ -31,6 +32,7 @@ export function useTagAutocomplete<T>(opts: { select: opts.select, placeholderData: keepPreviousData, gcTime: opts.nameContains?.length > 0 ? 60_000 : 3_600_000, + enabled: opts.enabled, }, ); } |
