fix(workspace-cleanup): unify chip clears on the merged updater form

#15298 landed the functional-update `patchFilters`, so `replaceFilters` uses the
same idiom rather than reading the store directly. Same guarantee, one pattern.
This commit is contained in:
Brennan Benson
2026-08-24 10:44:27 -07:00
parent 8710cf8aa1
commit dce8e40dca
2 changed files with 3 additions and 5 deletions
@@ -105,7 +105,6 @@ describe('useWorkspaceCleanupBrowseState', () => {
field: 'size',
direction: 'desc'
})
})
})
it('keeps a cleared chip cleared when a facet patch lands in the same tick', () => {
@@ -60,12 +60,11 @@ export function useWorkspaceCleanupBrowseState(): WorkspaceCleanupBrowseControll
[updateBrowse]
)
// Why read the store rather than the rendered `browse`: a chip click and any other
// filter write can land in the same tick, and the rendered snapshot would drop one.
// Same updater form as patchFilters: a chip clear and a facet patch can land in one
// tick, and whichever read the render snapshot would undo the other.
const replaceFilters = useCallback<WorkspaceCleanupBrowseController['replaceFilters']>(
(transform) => {
const current = useAppStore.getState().workspaceCleanupBrowse
updateBrowse({ ...current, filters: transform(current.filters) })
updateBrowse((current) => ({ ...current, filters: transform(current.filters) }))
},
[updateBrowse]
)