Skip to content

fix(pages): replace history for same-page action re-renders - #566

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
0froq:fix/action-url-history
Oct 26, 2026
Merged

cpojer merged 1 commit into
voidzero-dev:mainfrom
0froq:fix/action-url-history

Conversation

@0froq

@0froq 0froq commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #527

Summary

Named actions no longer pollute history when they re-render the current page. #530 already removed ?actionName from the committed URL; #531 still used pushState for every mutation, so each useForm('/db?create') / action() submit added another back-stack entry at /db.

  • Same-document mutations use replaceState instead of pushState.
  • mutationCommitUrl() prefers the server pageData.url when the action updates query params on the same path (e.g. POST /books?delete → /books?page=2 still pushes once).

Tests

Updated POST history expectations to replaceState when the browser URL already matches the committed page URL. Added coverage for URL-changing POSTs and repeated same-page named-action submits.

vp test run packages/void/test/unit/pages-client.test.ts — 69/69 passed. 🐸

Fixes voidzero-dev#527

## Summary

Named actions no longer pollute history when they re-render the current page. voidzero-dev#530 already removed `?actionName` from the committed URL; voidzero-dev#531 still used `pushState` for every mutation, so each `useForm('/db?create')` / `action()` submit added another back-stack entry at `/db`.

- Same-document mutations use `replaceState` instead of `pushState`.
- `mutationCommitUrl()` prefers the server `pageData.url` when the action updates query params on the same path (e.g. `POST /books?delete` → `/books?page=2` still pushes once).

## Tests

Updated POST history expectations to `replaceState` when the browser URL already matches the committed page URL. Added coverage for URL-changing POSTs and repeated same-page named-action submits.

`vp test run packages/void/test/unit/pages-client.test.ts` — 69/69 passed.

Co-authored-by: froQ <sayhola@froq.me>

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@cpojer
cpojer merged commit 4f3dcec into voidzero-dev:main Oct 26, 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.

Pages: actions commit the ?actionName URL to history

3 participants