mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-14 23:44:15 +00:00
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:
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 }
|
||||
|
||||
Reference in new issue
Block a user