Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- react, typescript
- 領域
- frontend
調査の方向性
バグは commitLocation にあります。ここでは先頭の # を付けない論理的な位置から __tempLocation を構築しています。さらに parseLocation が hash.slice(1) でそれを読み戻しています。まず issue の単独スクリプト(メモリ履歴、ハッシュ付きのマスク付きナビゲーション)で再現し、ナビゲーションごとにハッシュが1文字ずつ short くなることを確認してください。論理ハッシュが繰り返しのナビゲーションを経ても "anchor" のまま残り、ハッシュを伴うマスク付きナビゲーションを対象とする回帰テストがあれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Which project does this relate to? Router
Describe the bug
A navigation with mask stores the real (logical) location in history.state.__tempLocation. commitLocation spreads the built location into it, whose hash has no leading # (buildLocation returns hash: hash ?? ""). parseLocation then reads __tempLocation back with decodePath(hash.slice(1)), so the logical hash loses its first character. An app that carries the current hash forward loses one more character per navigation: anchor -> nchor -> chor -> hor.
Your Example Website or App
Standalone script below (Node 22, @tanstack/react-router 1.169.2; same code in router-core 1.171.39).
Steps to Reproduce the Bug or Issue
import { createRouter, createRootRoute, createRoute, createMemoryHistory } from "@tanstack/react-router"
const root = createRootRoute()
const home = createRoute({ getParentRoute: () => root, path: "/" })
const chat = createRoute({ getParentRoute: () => root, path: "/chats/$chatId" })
const router = createRouter({ routeTree: root.addChildren([home, chat]), history: createMemoryHistory({ initialEntries: ["/"] }) })
await router.load()
let hash = "anchor"
for (let i = 1; i <= 3; i++) {
void router.navigate({ to: "/", hash, mask: { to: "/chats/$chatId", params: { chatId: "c1" }, hash } })
await new Promise((r) => setTimeout(r, 50))
hash = router.parseLocation(router.history.location).hash
console.log(i, JSON.stringify(hash))
}
// 1 "nchor" 2 "chor" 3 "hor"
Expected behavior
The logical location parsed back from a masked entry keeps its hash: "anchor" every time.
Suggested fix
In commitLocation, store the hash with its # in __tempLocation, as parse expects (it already does for history.location):
__tempLocation: {
...nextHistory,
search: nextHistory.searchStr,
+ hash: nextHistory.hash ? `#${nextHistory.hash}` : "",
- 主要言語
- TypeScript
- スター
- 15.3k
- フォーク
- 1.9k
- 平均マージ
- 1日 5時間
- マージ済み PR(30日)
- 46
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/router のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)対応中かも @Sheraff が 27 日前に担当しました。 オープンpackage: router-generator performance
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiers対応中かも @Sheraff が 27 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
docs(router): clarify static title fallback in SPA mode対応中かも @Rohan-Dedhia が 17 日前に担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
router.startViewTransition leaves the ready/finished promises unhandled, so a skipped transition throws an unhandled AbortError対応中かも @unjica が 29 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
TanStack/router#8776 · コメント 3 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
TanStack/router の issue をすべて見る
似ている issue
-
Add: GTrekkerオープンcheck:passed streams:add
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
area: ui Bug Payload OSS
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
payloadcms/payload#19839 ·
メンテナーはふだん 1 日以内に返信
-
external
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ClickHouse/ClickStack#3761 ·
メンテナーはふだん 1 日以内に返信
-
fix(auth): add the email OTP verification step to Pollar login対応中かも @akansnoro が今日担当しました。 オープンStellar Wave
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
safetrustcr/dApp-SafeTrust#584 · コメント 10 件 ·
メンテナーはふだん 1 日以内に返信
-
The manager preset saves launch definitions without the required file and digest pair対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信