Skip to content

fix(Link): treat ? as a boundary in subroute matching - #1340

Merged
nebojsa-peric merged 1 commit into
masterfrom
fix/master/link-active-ignore-query
Oct 7, 2026
Merged

nebojsa-peric merged 1 commit into
masterfrom
fix/master/link-active-ignore-query

Conversation

@nebojsa-peric

Copy link
Copy Markdown
Collaborator

A page carrying query state (e.g. ~/items?filter=x) is still on its href's route, but match="subroute" rejected it: the character after the href was ?, not /. A subroute below the href with a query (~/items/42?tab=log) already matched, which made the bug easy to miss — nav items highlighted on detail pages with query state but went dark on their own list page the moment it carried a filter in the URL. Route matching already tolerates the query string, so Link and Route disagreed about whether the same URL was "on" the route.

The fix is one clause: subroute accepts ? as a boundary character alongside /. equal stays full-string equality (query-routed navs like ~/docs?topic=a vs ?topic=b keep exact matching) and prefix was never affected.

url href ~/items subroute (before) after
~/items active active
~/items?filter=x inactive active
~/items/42?tab=log active active
~/items-archive inactive inactive

Link.spec.tsx covers all three match modes against exact/query/subroute/sibling-prefix urls, query-carrying hrefs, and the active override. litmus/bugs/link-active-query-string.js renders every scenario through both the old matcher (inlined as a subclass) and the fixed one side by side — flip the import in litmus/index.js to play with it.

@nebojsa-peric
nebojsa-peric merged commit 053d0c2 into master Oct 7, 2026
2 checks passed
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