Skip to content

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

Open
0froq wants to merge 1 commit into
voidzero-dev:mainfrom
0froq:fix/action-url-history
Open

0froq wants to merge 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>

This branch has not been deployed

No deployments
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

2 participants