Repository navigation
fix: stop adding the base twice to paths nodes in navigate and useLinkState - #717
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: e29aeda The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
ryansolid
pushed a commit
that referenced
this pull request
Nov 4, 2026
With a leading slash a full path, a paths node's brand resolves to itself, so navigate goes back to plain resolution and useLinkState only reads the brand (hash mode's toString is the display href). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWNSSgtemsSYsaX2hXE
Member
|
Landed in #718, which keeps this PR's commit. The fix grew into a broader rule: under a Generated by Claude Code |
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.
Under a
base,navigate(paths.about)anduseLinkState(paths.about)add the base twice. Withbase: "/app",navigate(paths.about)goes to/app/app/about, which matches no route, anduseLinkState(paths.about)is never active or current on/app/about. Both are documented usages (navigate(paths.users(2)), and the TabLink example foruseLinkState).Root cause
A paths node already includes the base, both in its
toString()and in itsSymbol.for("solid.Href")brand.navigateread the brand and then passed it throughroute.resolvePath, which prefixes the base onto any path that starts with/.useLinkStatecoerced the node withString()and resolved it the same way. UnderhashHistorythat coercion produced the display href (#/about), souseLinkState(paths.about)was never current there either, with or without a base.Changes
navigateuses a node's brand as the resolved target, without resolving it again.useLinkStatereads the brand when there is one and resolves plain strings as before. Plain strings stay relative to the base, asclaims.spec.tsxdocuments, souseLinkState(() => "/about")andnavigate("/about")behave as they did.Verification
test/paths-base.spec.tsxcoversnavigateanduseLinkStatewith a node under a base (memory history), with a node underhashHistory, and with both together. All four tests fail onnextand pass with this change.npx vitest run: 732 passednpx vitest run --config vitest.config.server.ts: 105 passednpm run test:typesandnpm run build: passOpen
Under a base,
redirect(paths.login)from a query still lands on/app/app/login. The brand puts/app/loginintoLocation, and the client treats a single-slashLocationas relative to the base, as the README documents. A raw HTTP redirect treats the same header as a full document path, so fixing this means choosing between those two rules. This PR leaves it alone. Zero-argument calls such aspaths.about()return a plain string, so they also follow the base-relative string rule.🤖 Generated with Claude Code