feat: session-persistent list filters (issue #3789 Deliverable B) - #5998
Draft
weimiao67 wants to merge 3 commits into
Draft
feat: session-persistent list filters (issue #3789 Deliverable B)#5998weimiao67 wants to merge 3 commits into
weimiao67 wants to merge 3 commits into
Conversation
Filter selections (and the selected fiscal year) on the list pages now persist across client-side navigation for the duration of the session, so returning to a list via breadcrumb keeps the user's filters applied. Filters are intentionally lost on browser refresh / new tab (in-memory Redux) and cleared on logout. - Extend sessionUISlice with a `listFilters` sub-state keyed by page (agreements, cans, budgetLines, portfolios, projects, procurementDashboard). Default shapes copied verbatim from each page's original useState; selectedFiscalYear persisted alongside filters where the resolved query blends both. Logout reset is the same single extraReducers hook shared with the breadcrumb trail. - Add useListFilters(page) hook exposing a useState-compatible API (object OR functional-updater form) so the *FilterButton/*FilterTags sub-components keep working unchanged; updaters resolve against the latest committed store state. - Refactor all 6 list pages to source filters (and FY) from the slice. - Fix CANFilterButton reference-equality budget check (compare by value, not ===) now that budget can originate from the persisted slice. - Tests: slice listFilters reducers + logout reset; useListFilters hook (persist across remount, logout clear, per-page isolation, updater form). Update page/hook tests to provide the sessionUI reducer and reset session state between cases. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up to the Deliverable B commit, fixing defects surfaced in review: - fix: CANFilterButton full-range selection now clears a persisted budget filter (set `budget: []`) instead of retaining the stale prevState value. The value-based comparison introduced in Deliverable B made this branch reachable, exposing the latent bug. Add a regression test. - fix: unify fiscal-year-change reset across all FY-aware list pages via a new `changeFiscalYear` in useListFilters that dispatches resetListFilters + setListFiscalYear. Previously CANs reset nothing and Projects cleared only the FY key on FY change; now Agreements, CANs, Projects, and Portfolios all consistently reset filters (matching the product decision "changing FY still clears other filters"). This also fixes stale cross-FY filters persisting after an FY switch, and the Portfolio slider bounds recompute correctly on FY change. - harden: useListFilters selectors/getState now defensively chain `state.sessionUI?.listFilters?.[page]?.`, matching Breadcrumb. - refactor: extract buildPageState() as the single clone source for both initial-state construction and resetListFilters (removes duplication); activate the previously-unused resetListFilters action; drop the AgreementsList shallow-spread aliasing of exported defaults and the Portfolio inline-default duplication. - test: add changeFiscalYear coverage and CANFilterButton budget-clear test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…on-persistent-filters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Filter selections on the list pages now persist across client-side navigation for the duration of the session, so returning to a list (e.g. via a breadcrumb) keeps the user's filters — and selected fiscal year — applied. Filters are intentionally lost on browser refresh / new tab (in-memory Redux) and cleared on logout.
Approach: extend the session-scoped
sessionUISlice(introduced in Deliverable A) with alistFilterssub-state keyed by page, and add auseListFilters(page)hook exposing auseState-compatible API (object or functional-updater form) so the existing*FilterButton/*FilterTagssub-components keep working unchanged. All six list pages source their filters (and fiscal year, where applicable) from the slice instead of localuseState. Logout reset reuses A's singleextraReducershook.Pages: Agreements, CANs, Budget Lines, Portfolios, Projects, Procurement Dashboard.
Key pieces:
sessionUISlicelistFilters— per-page default shapes copied verbatim from each page's originaluseState;selectedFiscalYearpersisted alongside filters where the resolved query blends both.setListFilters/setListFiscalYear/resetListFiltersactions;buildPageStateis the single deep-clone source for init + reset.useListFilters(page)—filters/setFilters/selectedFiscalYear/setSelectedFiscalYear, pluschangeFiscalYearwhich atomically resets the page's filters and sets the new FY (one shared code path for all FY-aware pages).CANFilterButton— fixed a reference-equality budget check to compare by value.This is Deliverable B of the issue and stacks on Deliverable A (#5995) — the PR is based on the A branch so the diff shows only B's changes. Rebase to
mainonce A merges.Issue
#3789
How to test
Verified locally by driving the running stack (apply → navigate → back → still applied; FY persists; refresh clears).
A11y impact
No markup/ARIA changes; filter state moves from local component state to Redux with identical rendering.
Storybook
Changes are in a Redux slice, a hook, and page/hook wiring — no
src/components/UI/component added or changed.Definition of Done Checklist
Notes for reviewers
Links