Skip to content

Comments

Use view transitions for failed form submissions#1457

Open
tvararu wants to merge 1 commit intohotwired:mainfrom
tvararu:form-view-transition
Open

Use view transitions for failed form submissions#1457
tvararu wants to merge 1 commit intohotwired:mainfrom
tvararu:form-view-transition

Conversation

@tvararu
Copy link

@tvararu tvararu commented Nov 5, 2025

View transitions don't work when forms return 422 or 500, because formSubmissionFailedWithResponse calls view.renderPage() directly.

This change implements ViewTransitioner and wraps the existing render and scroll calls with .renderChange. Reviewing without whitespace changes (-w) is recommended.

The new test is similar to drive_view_transition_tests.js, but I had to add a /reject/view-transition route to the test server.

New tests pass:

$ yarn test:browser src/tests/functional/form_submission_view_transition_tests.js
yarn run v1.22.22
$ playwright test src/tests/functional/form_submission_view_transition_tests.js

Running 4 tests using 2 workers

  ✓  1 …n_tests.js:16:5 › form submission with 422 response triggers view transition (1.1s)
  ✓  2 …n_tests.js:16:5 › form submission with 422 response triggers view transition (1.4s)
  ✓  3 …_tests.js:25:5 › form submission with 500 response triggers view transition (726ms)
  ✓  4 …_tests.js:25:5 › form submission with 500 response triggers view transition (603ms)

  4 passed (4.0s)
✨  Done in 4.88s.

Before: No transitions

Screen.Recording.2025-11-05.at.11.20.36.mov

After: With transitions

Screen.Recording.2025-11-05.at.11.21.27.mov

@tvararu tvararu force-pushed the form-view-transition branch from de6c19f to 0b39d4b Compare November 19, 2025 01:28
View transitions don't work when forms return 422 or 500, because
`formSubmissionFailedWithResponse` calls `view.renderPage()` directly.

This change implements `ViewTransitioner` and wraps the existing render
and scroll calls with `.renderChange`. Reviewing without whitespace
changes (`-w`) is recommended.

The new test is similar to `drive_view_transition_tests.js`, but I had
to add a `/reject/view-transition` route to the test server.
@tvararu tvararu force-pushed the form-view-transition branch from 0b39d4b to ff391fb Compare November 19, 2025 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants