From d717add78ac02809976f2a4d942cc44e69dd73fd Mon Sep 17 00:00:00 2001 From: Alan Buscaglia Date: Mon, 30 Mar 2026 17:56:03 +0200 Subject: [PATCH] fix(ui): trigger refresh imperatively on search commit instead of useEffect Replace useEffect-based refresh on resourceSearch change with imperative queueMicrotask(() => inlineRef.current?.refresh()) in the onSearchCommit callback. This follows the project convention of avoiding useState+useEffect patterns that mirror props. The hook uses refs (filtersRef.current) which update on render but don't auto-trigger fetches. queueMicrotask ensures the state update from setResourceSearch is flushed before refresh reads the new filters. --- .../findings/table/findings-group-table.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ui/components/findings/table/findings-group-table.tsx b/ui/components/findings/table/findings-group-table.tsx index ccad4fe483..f2c4f7879f 100644 --- a/ui/components/findings/table/findings-group-table.tsx +++ b/ui/components/findings/table/findings-group-table.tsx @@ -204,7 +204,19 @@ export function FindingsGroupTable({ } controlledSearch={expandedCheckId ? resourceSearchInput : undefined} onSearchChange={expandedCheckId ? setResourceSearchInput : undefined} - onSearchCommit={expandedCheckId ? setResourceSearch : undefined} + onSearchCommit={ + expandedCheckId + ? (value: string) => { + setResourceSearch(value); + // Trigger re-fetch with updated filters imperatively. + // The hook uses refs (no auto-refetch on prop change), so + // we call refresh() after the state update is committed. + // queueMicrotask ensures the new resourceSearch is in the + // filters object before refresh reads filtersRef.current. + queueMicrotask(() => inlineRef.current?.refresh()); + } + : undefined + } searchBadge={ expandedGroup ? { label: expandedGroup.checkTitle, onDismiss: handleCollapse }