diff --git a/src/core/drive/page_view.js b/src/core/drive/page_view.js
index 1583f25a0..6a40a94d9 100644
--- a/src/core/drive/page_view.js
+++ b/src/core/drive/page_view.js
@@ -16,7 +16,7 @@ export class PageView extends View {
}
renderPage(snapshot, isPreview = false, willRender = true, visit) {
- const shouldMorphPage = this.isPageRefresh(visit) && this.snapshot.shouldMorphPage
+ const shouldMorphPage = this.isPageRefresh(visit) && snapshot.shouldMorphPage
const rendererClass = shouldMorphPage ? MorphRenderer : PageRenderer
const renderer = new rendererClass(this.snapshot, snapshot, PageRenderer.renderElement, isPreview, willRender)
diff --git a/src/tests/fixtures/422_morph.html b/src/tests/fixtures/422_morph.html
new file mode 100644
index 000000000..d87ec4161
--- /dev/null
+++ b/src/tests/fixtures/422_morph.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+ Unprocessable Entity
+
+
+
+ Unprocessable Entity
+
+
+ Frame: Unprocessable Entity
+
+
+
diff --git a/src/tests/fixtures/page_refresh.html b/src/tests/fixtures/page_refresh.html
index c0586677f..ee2ff20b6 100644
--- a/src/tests/fixtures/page_refresh.html
+++ b/src/tests/fixtures/page_refresh.html
@@ -131,7 +131,7 @@ Element with Stimulus controller
-
diff --git a/src/tests/functional/autofocus_tests.js b/src/tests/functional/autofocus_tests.js
index 9cc49afe3..726ef8307 100644
--- a/src/tests/functional/autofocus_tests.js
+++ b/src/tests/functional/autofocus_tests.js
@@ -59,7 +59,9 @@ test("autofocus from a Turbo Stream message does not leak a placeholder [id]", a
`)
})
+
await expect(page.locator("#container-from-stream input")).toBeFocused()
+
})
test("receiving a Turbo Stream message with an [autofocus] element when an element within the document has focus", async ({ page }) => {
diff --git a/src/tests/server.mjs b/src/tests/server.mjs
index 10eab3abb..76cdaf464 100644
--- a/src/tests/server.mjs
+++ b/src/tests/server.mjs
@@ -61,6 +61,13 @@ router.post("/reject/tall", (request, response) => {
response.status(parseInt(status || "422", 10)).sendFile(fixture)
})
+router.post("/reject/morph", (request, response) => {
+ const { status } = request.body
+ const fixture = path.join(__dirname, `../../src/tests/fixtures/422_morph.html`)
+
+ response.status(parseInt(status || "422", 10)).sendFile(fixture)
+})
+
router.post("/reject", (request, response) => {
const { status } = request.body
const fixture = path.join(__dirname, `../../src/tests/fixtures/${status}.html`)