Skip to content

Commit

Permalink
Revert behavior of hotwired#1079
Browse files Browse the repository at this point in the history
  • Loading branch information
krschacht committed Feb 26, 2024
1 parent 4b1f3f8 commit 48b520a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/drive/page_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class PageView extends View {
}

isPageRefresh(visit) {
return !visit || (this.lastRenderedLocation.pathname === visit.location.pathname && visit.action === "replace")
return !visit || (this.lastRenderedLocation.href === visit.location.href && visit.action === "replace")
}

isReplaceMethodMorph(visit) {
Expand Down
3 changes: 2 additions & 1 deletion src/tests/fixtures/page_refresh.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ <h3>Element with Stimulus controller</h3>
</label>
<button>Form with params to refresh the page</button>
</form>
<p><a id="replace-link" data-turbo-action="replace" href="/src/tests/fixtures/page_refresh.html?param=something">Link with params to refresh the page</a></p>
<p><a id="replace-link" data-turbo-action="replace" href="/src/tests/fixtures/page_refresh.html?tab=something">Link with params should not refresh the page</a></p>
<p><a id="replace-link-method-morph" data-turbo-action="replace" data-turbo-replace-method="morph" href="/src/tests/fixtures/page_refresh.html?tab=something">Link with different params will morph if specified</a></p>
<p><a id="refresh-link" data-turbo-action="replace" href="/src/tests/fixtures/page_refresh.html">Link to the same page</a></p>
<p><a id="link" href="/src/tests/fixtures/one.html">Link to another page</a></p>

Expand Down
9 changes: 8 additions & 1 deletion src/tests/functional/page_refresh_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,17 @@ test("page refreshes cause a reload when assets change", async ({ page }) => {
await expect(page.locator("#new-stylesheet")).toHaveCount(0)
})

test("renders a page refresh with morphing when the paths are the same but search params are different", async ({ page }) => {
test("does not render a page refresh with morphing when params are different", async ({ page }) => {
await page.goto("/src/tests/fixtures/page_refresh.html")

await page.click("#replace-link")
await nextEventNamed(page, "turbo:render", { renderMethod: "replace" })
})

test("does render a page refresh with morphing when params are different when explicitly specified", async ({ page }) => {
await page.goto("/src/tests/fixtures/page_refresh.html")

await page.click("#replace-link-method-morph")
await nextEventNamed(page, "turbo:render", { renderMethod: "morph" })
})

Expand Down

0 comments on commit 48b520a

Please sign in to comment.