diff --git a/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.test.tsx b/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.test.tsx index 70f8f903afe..061fdf3ea9e 100644 --- a/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.test.tsx +++ b/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.test.tsx @@ -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', () => { diff --git a/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.ts b/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.ts index 87e15404527..3651f4e01a0 100644 --- a/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.ts +++ b/src/renderer/src/components/workspace-cleanup/use-workspace-cleanup-browse-state.ts @@ -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( (transform) => { - const current = useAppStore.getState().workspaceCleanupBrowse - updateBrowse({ ...current, filters: transform(current.filters) }) + updateBrowse((current) => ({ ...current, filters: transform(current.filters) })) }, [updateBrowse] )