Skip to content

fix: sync selected market with marketName on back/forward navigation - #3174

Draft
grothem wants to merge 2 commits into
mainfrom
fix/market-sync-on-back-nav
Draft

grothem wants to merge 2 commits into
mainfrom
fix/market-sync-on-back-nav

Conversation

@grothem

@grothem grothem commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Pressing browser Back after switching markets changed the URL's ?marketName= but left the previously selected market on screen (report).

Each market pick pushes a history entry with ?marketName=, but the store only read that param once, on first page load. Two changes:

  • Sync on Back/Forward (src/store/root.ts): a popstate listener switches to the URL's market when it differs from the selected one. It passes omitQueryParameterUpdate = true, so it never writes the URL. popstate fires only on history traversal, so the app's own URL writes never trigger it.
  • Stamp the entry being left (src/store/utils/queryParams.ts, protocolDataSlice.ts): if you switch markets from a URL with no marketName (e.g. you landed on /markets), that entry is first rewritten in place with the market it was showing. Without this, Back returned to a URL with no market to restore.

Routes without marketName keep the current market, and setCurrentMarket already ignores unknown market ids.

Test plan

Verified in a headless browser against the local dev server, starting from /markets/ with no param:

  • Pick Polygon, then BNB Chain, then Back → Polygon
  • Back again → URL ?marketName=proto_mainnet_v3, market Core (the case without a starting param)
  • Forward → Polygon
  • A full reload with ?marketName= still loads that market

🤖 Generated with Claude Code

… navigation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
interface Ready Ready Preview Nov 5, 2026 10:39pm UTC

Request Review

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

Stamp the entry being left with its market before pushing the new one, and
sync on popstate so that stamp can't trigger the listener mid-switch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

This branch was successfully deployed

1 active deployment
Preview — 31fcae9f Deployed Nov 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant