Pages: preserveState prevents the destination URL from being committed
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript, vite
调研方向
Start in packages/void/src/pages/navigation-engine.ts, especially makeCommit() and its history-writing condition, then trace how normal visits, router.refresh(), and back/forward navigation select commit behavior. Run the reported unit tests with vp test run and locate the shared-router regression tests. Done means preserveState visits update the URL, replace still replaces, refresh and history navigation add no entries, and tests cover state preservation and URL behavior.
由索引模型根据 Issue 内容生成。
描述
Description
Calling router.visit('/settings', { preserveState: true }) updates the rendered page, but leaves the browser URL pointing to the previous page.
This appears to couple component state preservation with history updates.
Environment
- Commit:
2ceab89154dc6e0c3fa5525f7bd4d1d5f3d0aa64 - Package version in the repository:
1.1.12 - Chromium Headless Shell:
134.0.6998.35 - Playwright:
1.64.1
Steps to reproduce
- Start on
/case. - Navigate using:
await router.visit('/settings', {
preserveState: true,
});
- Return a valid Pages response for
/settings. - Compare the rendered page with
window.location.pathname.
Actual behavior
The destination page renders, but the address bar remains on /case.
In an isolated browser fixture using the production createVoidRouter():
| Value | Result |
|---|---|
| Rendered page | /settings |
window.location.pathname |
/case |
router.path after the visit |
/case |
This reproduced in all three browser runs. A direct regression test against the shared router also fails because history.pushState() is not called.
The unit tests were run with vp test run. The browser fixture was run separately through a Node.js script using Playwright; it was not run as an existing Void browser integration suite. The fixture exercises the actual client runtime with a small HTTP server; this was not a full production-build test across every adapter.
Expected behavior
The rendered page and browser URL should both reflect /settings.
preserveState should control component state preservation independently of whether a normal visit writes history. replace should continue to select between replacing and adding an entry.
Relevant implementation
In makeCommit(), history updates are skipped whenever preserveState is true:
if (!options.preserveState) {
const historyUrl = commitTarget.fetchUrl + commitTarget.hash;
scrollRestoration.writeHistory(historyUrl, !!options.replace);
}
Separating history-writing decisions from state preservation would also need to retain the existing behavior of router.refresh() and back/forward navigation, which should not add history entries.
Acceptance criteria
- A normal visit with
preserveState: trueupdates the destination URL. replace: truereplaces the current entry.router.refresh()and back/forward navigation do not add entries.- Regression coverage checks both state preservation and URL/history behavior.
- 主要语言
- TypeScript
- 星标
- 402
- 派生
- 32
- 平均合并
- 10 小时 51 分钟
- 30 天内合并 PR
- 100
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
voidzero-dev/void 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
voidzero-dev/void#529 ·
维护者通常 1 天内回复
-
bug
难度 1/5 1-3 小时 新手友好度 78/100
voidzero-dev/void#428 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 56/100
voidzero-dev/void#527 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 54/100
voidzero-dev/void#525 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 67/100
voidzero-dev/void#524 ·
维护者通常 1 天内回复
查看 voidzero-dev/void 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
paperclipai/paperclip#17151 ·
维护者通常 1 天内回复
-
needs-triage
难度 2/5 1-3 小时 新手友好度 83/100
AgoraIO-Extensions/agent-infra#3159 ·
维护者通常 1 天内回复
-
blocklist addition
难度 1/5 1 小时以内 新手友好度 66/100
MetaMask/eth-phishing-detect#304596 ·
维护者通常 1 天内回复
-
friction
难度 2/5 1-3 小时 新手友好度 70/100
kentcdodds/kody#4142 ·
-
[Bug] Statistics | Task statistics are always empty on MikroORM with MySQL or SQLite可能已有人在做 @NdekoCode 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
ever-co/ever-gauzy#11214 ·
维护者通常 1 天内回复