From da58bb382e6dc24da58c46c4df182983ec3a011e Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Mon, 24 Aug 2026 21:19:58 +0100 Subject: [PATCH] feat: show secondary search filters only when applied Created by and Labels now stay hidden until they hold a value; a Filter button at the right end of the bar lists the hidden ones and opens the picked filter's dropdown immediately. --- .../search/components/creator-filter-menu.tsx | 13 ++- .../search/components/label-filter-menu.tsx | 6 ++ .../components/search-spotlight-filters.tsx | 102 ++++++++++++++---- 3 files changed, 99 insertions(+), 22 deletions(-) diff --git a/apps/client/src/features/search/components/creator-filter-menu.tsx b/apps/client/src/features/search/components/creator-filter-menu.tsx index 059422a91..fba152d9b 100644 --- a/apps/client/src/features/search/components/creator-filter-menu.tsx +++ b/apps/client/src/features/search/components/creator-filter-menu.tsx @@ -21,6 +21,8 @@ type CreatorFilterMenuProps = { | "top-end" | "top"; zIndex?: number; + opened?: boolean; + onOpenChange?: (opened: boolean) => void; }; export function CreatorFilterMenu({ @@ -30,6 +32,8 @@ export function CreatorFilterMenu({ width = 280, position = "bottom-end", zIndex, + opened, + onOpenChange, }: CreatorFilterMenuProps) { const { t } = useTranslation(); const [searchQuery, setSearchQuery] = useState(""); @@ -46,7 +50,14 @@ export function CreatorFilterMenu({ const users: IUser[] = (suggestion?.users as IUser[]) ?? []; return ( - + {children} void; }; export function LabelFilterMenu({ @@ -36,6 +38,8 @@ export function LabelFilterMenu({ width = 280, position = "bottom-end", zIndex, + opened, + onOpenChange, }: LabelFilterMenuProps) { const { t } = useTranslation(); const scheme = useComputedColorScheme("light"); @@ -61,6 +65,8 @@ export function LabelFilterMenu({ width={width} position={position} zIndex={zIndex} + opened={opened} + onChange={onOpenChange} closeOnItemClick={false} > {children} diff --git a/apps/client/src/features/search/components/search-spotlight-filters.tsx b/apps/client/src/features/search/components/search-spotlight-filters.tsx index 8a7886609..c171e23e2 100644 --- a/apps/client/src/features/search/components/search-spotlight-filters.tsx +++ b/apps/client/src/features/search/components/search-spotlight-filters.tsx @@ -11,6 +11,7 @@ import { import { IconChevronDown, IconBuilding, + IconPlus, IconFileDescription, IconCheck, IconUser, @@ -52,6 +53,7 @@ export function SearchSpotlightFilters({ null ); const [selectedLabelIds, setSelectedLabelIds] = useState([]); + const [openedFilter, setOpenedFilter] = useState(null); const [workspace] = useAtom(workspaceAtom); const { data: spacesData } = useGetSpacesQuery({ limit: 100 }); @@ -104,6 +106,24 @@ export function SearchSpotlightFilters({ } }; + const showCreatorFilter = !!selectedCreatorId || openedFilter === "creator"; + const showLabelFilter = + contentType !== "attachment" && + (selectedLabelIds.length > 0 || openedFilter === "labels"); + + const addableFilters: { key: string; label: string; icon: typeof IconUser }[] = + []; + if (!showCreatorFilter) { + addableFilters.push({ + key: "creator", + label: t("Created by"), + icon: IconUser, + }); + } + if (contentType !== "attachment" && !showLabelFilter) { + addableFilters.push({ key: "labels", label: t("Labels"), icon: IconTag }); + } + return (
{workspace?.settings?.ai?.search === true && ( @@ -219,35 +239,41 @@ export function SearchSpotlightFilters({
- - - + + + )} - {contentType !== "attachment" && ( + {showLabelFilter && ( setOpenedFilter(opened ? "labels" : null)} > + + + {addableFilters.map((filter) => ( + } + onClick={() => setOpenedFilter(filter.key)} + > + {filter.label} + + ))} + +
+ )} ); }