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.
This commit is contained in:
Alan Buscaglia committed 2026-03-30 17:56:03 +02:00
1 parent b129abe42e
commit d717add78a
1 file changed
+13 -1
@@ -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 }