feat: browse label-filtered pages without a query

Selecting labels now lists their pages newest-first before any text is
typed, on both the Postgres and Typesense drivers.
This commit is contained in:
Philipinho
2026-08-24 23:09:51 +01:00
parent caa582606b
commit 875bc42610
5 changed files with 35 additions and 26 deletions
@@ -106,6 +106,8 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
}
}, [aiSearchError, t]);
const isLabelBrowse = (filters.labelIds?.length ?? 0) > 0;
// Determine result type for rendering
const isAttachmentSearch =
filters.contentType === "attachment" && hasAttachmentIndexing;
@@ -227,17 +229,19 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
</>
) : (
<>
{query.length === 0 && resultItems.length === 0 && (
{query.length === 0 && !isLabelBrowse && resultItems.length === 0 && (
<Spotlight.Empty>{t("Start typing to search...")}</Spotlight.Empty>
)}
{query.length > 0 && !isFetching && resultItems.length === 0 && (
<Spotlight.Empty>{t("No results found...")}</Spotlight.Empty>
)}
{(query.length > 0 || isLabelBrowse) &&
!isFetching &&
resultItems.length === 0 && (
<Spotlight.Empty>{t("No results found...")}</Spotlight.Empty>
)}
{resultItems.length > 0 && <>{resultItems}</>}
{query.length > 0 && isFetching && (
{(query.length > 0 || isLabelBrowse) && isFetching && (
<Spotlight.Empty>
<Text size="sm" style={{ marginTop: 10 }}>
{t("Searching...")}
@@ -39,11 +39,11 @@ export function useUnifiedSearch(
return await searchPage(backendParams);
}
},
enabled: !!params.query && enabled,
enabled: (!!params.query || (params.labelIds?.length ?? 0) > 0) && enabled,
// keep previous results only within the same search type; page results
// rendered as attachments (or vice versa) crash on missing fields
placeholderData: (previousData, previousQuery) => {
if (params.query.length < 1) return undefined;
if (!params.query && !params.labelIds?.length) return undefined;
if (previousQuery && previousQuery.queryKey[1] !== searchType) {
return undefined;
}