Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix(secrets): stop overview search reverting after clear and add a clear action to no-matches state (#8812)
Andrew Huang297301909a2d
diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsxindex 589facb758..9246cf4ecb 100644--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx@@ -395,6 +395,7 @@ const OverviewPageContent = () => {select: (el) => ({secretPath: el.secretPath,search: el.search,+ clearSearch: el.clearSearch,environments: el.environments,dynamicSecretId: el.dynamicSecretId,honeyTokenId: el.honeyTokenId,@@ -563,10 +564,10 @@ const OverviewPageContent = () => {// (not mount-only) because the tree is rendered inside this page, so navigating from a node// updates the params without remounting.useEffect(() => {- const { search, tags, filterBy, environments: envSlugs, ...query } = routerSearch;+ const { search, clearSearch, tags, filterBy, environments: envSlugs, ...query } = routerSearch;const hasEnvLink = Boolean(envSlugs?.length);- if (!search && !tags && !filterBy && !hasEnvLink) return;+ if (!search && !clearSearch && !tags && !filterBy && !hasEnvLink) return;// Env link present but envs not loaded yet → wait so we don't strip it before applying.if (hasEnvLink && userAvailableEnvs.length === 0) return;@@ -610,9 +611,12 @@ const OverviewPageContent = () => {}}+ if (clearSearch) setSearchFilter("");+navigate({ search: query, replace: true });}, [routerSearch.search,+ routerSearch.clearSearch,routerSearch.tags,routerSearch.filterBy,routerSearch.environments?.join(","),@@ -3911,6 +3915,13 @@ const OverviewPageContent = () => {}hasSearch={Boolean(searchFilter.trim())}onSearchAllFolders={() => setIsSearchAllFoldersOpen(true)}+ onClearSearch={() => {+ overviewTelemetry.interaction({+ action: "search-cleared",+ source: "empty-state"+ });+ setSearchFilter("");+ }}/>)}{showOverviewSkeleton ? (diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/EmptyResourceDisplay/EmptyResourceDisplay.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/EmptyResourceDisplay/EmptyResourceDisplay.tsxindex 8dad682837..a9a0b4e36f 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/EmptyResourceDisplay/EmptyResourceDisplay.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/EmptyResourceDisplay/EmptyResourceDisplay.tsx@@ -1,4 +1,4 @@-import { FolderPlusIcon, GlobeIcon, LayersIcon, PlusIcon, SearchIcon } from "lucide-react";+import { FolderPlusIcon, GlobeIcon, LayersIcon, PlusIcon, SearchIcon, XIcon } from "lucide-react";import { ProjectPermissionCan } from "@app/components/permissions";import {@@ -18,6 +18,7 @@ type Props = {onAddEnvironment?: () => void;hasSearch?: boolean;onSearchAllFolders?: () => void;+ onClearSearch?: () => void;isTableRow?: boolean;};@@ -27,6 +28,7 @@ export function EmptyResourceDisplay({onAddEnvironment,hasSearch,onSearchAllFolders,+ onClearSearch,isTableRow}: Props) {if (variant === "no-environments") {@@ -80,12 +82,22 @@ export function EmptyResourceDisplay({<EmptyTitle>{title}</EmptyTitle><EmptyDescription>{description}</EmptyDescription></EmptyHeader>- {hasSearch && onSearchAllFolders && (+ {hasSearch && (onSearchAllFolders || onClearSearch) && (<EmptyContent>- <Button variant="outline" size="xs" onClick={onSearchAllFolders}>- <GlobeIcon />- Search All Folders- </Button>+ <div className="flex gap-2">+ {onClearSearch && (+ <Button variant="outline" size="xs" onClick={onClearSearch}>+ <XIcon />+ Clear Search+ </Button>+ )}+ {onSearchAllFolders && (+ <Button variant="outline" size="xs" onClick={onSearchAllFolders}>+ <GlobeIcon />+ Search All Folders+ </Button>+ )}+ </div></EmptyContent>)}</Empty>diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/ResourceSearchInput.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/ResourceSearchInput.tsxindex d08e1da5b7..df19f94a42 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/ResourceSearchInput.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceSearchInput/ResourceSearchInput.tsx@@ -42,9 +42,14 @@ export const ResourceSearchInput = ({// local input state so typing doesn't re-render the whole tableconst [inputValue, setInputValue] = useState(externalValue);- const [debouncedInputValue] = useDebounce(inputValue);+ const [debouncedInputValue, setDebouncedInputValue] = useDebounce(inputValue);const previousExternalValue = useRef(externalValue);const lastEmittedValue = useRef(externalValue);+ // keeps a new onChange identity from re-running the sync effect with a stale debounced value+ const onChangeRef = useRef(onChange);+ useEffect(() => {+ onChangeRef.current = onChange;+ }, [onChange]);useEffect(() => {const transition = getResourceSearchStateTransition({@@ -60,15 +65,17 @@ export const ResourceSearchInput = ({previousExternalValue.current = transition.value;lastEmittedValue.current = transition.value;setInputValue(transition.value);+ setDebouncedInputValue(transition.value);return;}lastEmittedValue.current = transition.value;- onChange(transition.value);- }, [debouncedInputValue, externalValue, onChange]);+ onChangeRef.current(transition.value);+ }, [debouncedInputValue, externalValue, setDebouncedInputValue]);const handleClear = () => {setInputValue("");+ setDebouncedInputValue("");lastEmittedValue.current = "";onChange("");};diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/TableFilteredEmptyRow/TableFilteredEmptyRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/TableFilteredEmptyRow/TableFilteredEmptyRow.tsxindex afb59ca16c..dc70851644 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/TableFilteredEmptyRow/TableFilteredEmptyRow.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/TableFilteredEmptyRow/TableFilteredEmptyRow.tsx@@ -9,13 +9,15 @@ type Props = {isFiltered: boolean;hasSearch: boolean;onSearchAllFolders: () => void;+ onClearSearch: () => void;};export const TableFilteredEmptyRow = ({colSpan,isFiltered,hasSearch,- onSearchAllFolders+ onSearchAllFolders,+ onClearSearch}: Props) => {const contentRef = useRef<HTMLDivElement>(null);const [contentStyle, setContentStyle] = useState<CSSProperties>();@@ -46,6 +48,7 @@ export const TableFilteredEmptyRow = ({isFiltered={isFiltered}hasSearch={hasSearch}onSearchAllFolders={onSearchAllFolders}+ onClearSearch={onClearSearch}/></div></TableCell>