Skip to content

fix: match hash-history links against logical routes - #747

Open
clean99 wants to merge 2 commits into
solidjs:mainfrom
clean99:contrib/hash-history-link-state
Open

clean99 wants to merge 2 commits into
solidjs:mainfrom
clean99:contrib/hash-history-link-state

Conversation

@clean99

@clean99 clean99 commented Nov 22, 2026

Copy link
Copy Markdown

Fixes #746.

With hashHistory(), <a href="#/"> and <a href="#/applications"> are both marked current at the root, and neither is marked on Applications. A display string passed to useLinkState also disagrees with the equivalent paths node. The documented anchor/hook rule should compare logical routes.

Pass claimed hrefs through the history adapter before matching, and decode #/ display routes in useLinkState. Fragment-only strings such as #details retain route-relative resolution, including during SSR without browser globals. Keep logical paths, query-aware matching, eligibility rules, and browser-history behavior unchanged. Includes a patch changeset.

Reproduction: run the two-route app linked in #746 with router 2.0.1, open /#/, click Applications, then reload. With this fix, only the current page's link is marked on each step; browser-history behavior is unchanged.

Regression: pnpm exec vitest run test/link-state.spec.ts — four cases fail with the old sources and pass with the fix, covering anchor targets, href reclaim, hook strings, queries, fragments and a router base.

Server regression: pnpm exec vitest run --config vitest.config.server.ts test/server/ssr-link-state.spec.tsx checks fragment-only inputs and display routes, including query matching, without window.

Checks: pnpm test (766 client tests, 118 server tests, and types), pnpm build, and pnpx @arethetypeswrong/cli --pack . --profile esm-only pass.

Prepared by an automated contribution pipeline that I build and operate (https://github.com/clean99/software-factory); the tests and evidence above were produced by it.

@changeset-bot

changeset-bot Bot commented Nov 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c91cfd6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

[2.0.1] hashHistory: link claims and useLinkState ignore the hash, so aria-current/data-active are wrong on every link

1 participant