Skip to content

fix: persist filter and tab state on back-navigation (#871)#944

Open
aliangm wants to merge 1 commit intoentrius:testfrom
aliangm:fix/871-persist-filter-tab-state
Open

fix: persist filter and tab state on back-navigation (#871)#944
aliangm wants to merge 1 commit intoentrius:testfrom
aliangm:fix/871-persist-filter-tab-state

Conversation

@aliangm
Copy link
Copy Markdown

@aliangm aliangm commented May 5, 2026

Summary

Closes #871. Filter and inner-tab selections across several pages were stored in local useState, so navigating to a detail page and pressing browser Back silently reset them to the default. This swaps those call sites onto a shared sessionStorage-backed hook so selections survive the unmount/remount cycle but still reset when the tab is closed.

  • New shared hook: src/hooks/useSessionStoredState.tsuseState-shaped API backed by sessionStorage, with a type-guard parameter so stale values from older builds fall back to the default safely.
  • Replaced useState with useSessionStoredState at every call site listed in the issue, using the existing feature:field storage-key convention.

Call sites converted

Location Storage key
Watchlist → Repos status filter watchlist:repos:statusFilter
Watchlist → PRs status filter watchlist:prs:statusFilter
Miner profile → Open Issues "Mine" filter miner:openIssues:mineFilter
Miner profile → Open Issues "Others" filter miner:openIssues:otherFilter
Repository → Contributors program toggle repository:contributors:programTab
Repository → Issues filter repository:issues:filter
PR details inner tab pr:detailsTab
Issue details inner tab issue:detailsTab

MinerIssuesTable.tsx was intentionally left alone — it already persists via URL search params.

Test plan

For each row above: set a non-default filter/tab → click an item → press browser Back → confirm the selection is retained.

  • Watchlist → Repos: select Active → open a repo → Back → still Active
  • Watchlist → PRs: select Merged → open a PR → Back → still Merged
  • Miner profile → Open Issues: change Mine + Others filters → open an issue → Back → both retained
  • Repository → Contributors: switch to Issue Discovery → open a miner → Back → still on Issue Discovery
  • Repository → Issues: select Closed → open an issue → Back → still Closed
  • PR details: switch to Files or Conversation tab → open another PR → Back → tab retained
  • Issue details: switch to Submissions tab → open another issue → Back → tab retained
  • Close the tab and reopen the app → all selections reset to defaults (sessionStorage scope)
  • npm run build and npm run lint pass

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 5, 2026
@ventura-oss
Copy link
Copy Markdown
Contributor

Could you please resolve the merge conflicts so we can proceed with the review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Filter / tab state resets after navigating to a detail page and pressing Back

2 participants