-
Notifications
You must be signed in to change notification settings - Fork 441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Body is replaced twice when following a redirect during Drive visit #794
Comments
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this issue
Nov 25, 2022
Closes [hotwired#794][] Reverts the implementation change made in [hotwired#674][], and in its place passes `shouldCacheSnapshot: false` alongside `willRender: false` for the `action: "replace"` Visit proposed when following a redirect. In order to test this behavior, this commit introduces the `readBodyMutationLogs` test utility function, along with the `window.bodyMutationLogs` property and the `BodyMutationLog` type. `BodyMutationLog` instances are pushed onto the log `Array` whenever the `<body>` element is replaced. [hotwired#794]: hotwired#794 [hotwired#674]: hotwired#674
@calleluks thank you for opening this issue. I've opened #804 to try and resolve this. Could you test that change out locally to confirm if it resolves the issue? |
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this issue
Nov 27, 2022
Closes [hotwired#794][] Reverts the implementation change made in [hotwired#674][], and in its place passes `shouldCacheSnapshot: false` alongside `willRender: false` for the `action: "replace"` Visit proposed when following a redirect. In order to test this behavior, this commit introduces the `readBodyMutationLogs` test utility function, along with the `window.bodyMutationLogs` property and the `BodyMutationLog` type. `BodyMutationLog` instances are pushed onto the log `Array` whenever the `<body>` element is replaced. [hotwired#794]: hotwired#794 [hotwired#674]: hotwired#674
Hey @seanpdoyle, thanks so much for looking into this! The changes in #804 do resolve the issue! 🎉 |
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this issue
Dec 31, 2022
Closes [hotwired#794][] Reverts the implementation change made in [hotwired#674][], and in its place passes `shouldCacheSnapshot: false` alongside `willRender: false` for the `action: "replace"` Visit proposed when following a redirect. In order to test this behavior, this commit introduces the `readBodyMutationLogs` test utility function, along with the `window.bodyMutationLogs` property and the `BodyMutationLog` type. `BodyMutationLog` instances are pushed onto the log `Array` whenever the `<body>` element is replaced. [hotwired#794]: hotwired#794 [hotwired#674]: hotwired#674
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this issue
Dec 31, 2022
Closes [hotwired#794][] Reverts the implementation change made in [hotwired#674][], and in its place passes `shouldCacheSnapshot: false` alongside `willRender: false` for the `action: "replace"` Visit proposed when following a redirect. In order to test this behavior, this commit introduces the `readBodyMutationLogs` test utility function, along with the `window.bodyMutationLogs` property and the `BodyMutationLog` type. `BodyMutationLog` instances are pushed onto the log `Array` whenever the `<body>` element is replaced. [hotwired#794]: hotwired#794 [hotwired#674]: hotwired#674
dhh
pushed a commit
that referenced
this issue
Jan 4, 2023
* Fix flaky Firefox tests Some tests that visit the `navigation.html` fixture exercise scroll behavior by visiting links and other content that is below the fold. The `style="height: 200vh"` value declared on the page's `<section>` element is arbitrary, but double the screen size to force content below the fold. Unluckily, it cuts off _right_ at the beginning of the new `<iframe>` elements in Firefox browsers, which obscures the `<a>` element and prevents link clicks. To resolve that issue, this commit removes the `[style]` attribute, since the content is long enough to be scrollable. * Skip Snapshot Caching for redirect visits Closes [#794][] Reverts the implementation change made in [#674][], and in its place passes `shouldCacheSnapshot: false` alongside `willRender: false` for the `action: "replace"` Visit proposed when following a redirect. In order to test this behavior, this commit introduces the `readBodyMutationLogs` test utility function, along with the `window.bodyMutationLogs` property and the `BodyMutationLog` type. `BodyMutationLog` instances are pushed onto the log `Array` whenever the `<body>` element is replaced. [#794]: #794 [#674]: #674
Challenge-Guy
pushed a commit
to Challenge-Guy/turbo-cfm1
that referenced
this issue
Mar 8, 2025
* Fix flaky Firefox tests Some tests that visit the `navigation.html` fixture exercise scroll behavior by visiting links and other content that is below the fold. The `style="height: 200vh"` value declared on the page's `<section>` element is arbitrary, but double the screen size to force content below the fold. Unluckily, it cuts off _right_ at the beginning of the new `<iframe>` elements in Firefox browsers, which obscures the `<a>` element and prevents link clicks. To resolve that issue, this commit removes the `[style]` attribute, since the content is long enough to be scrollable. * Skip Snapshot Caching for redirect visits Closes [hotwired/turbo#794][] Reverts the implementation change made in [hotwired/turbo#674][], and in its place passes `shouldCacheSnapshot: false` alongside `willRender: false` for the `action: "replace"` Visit proposed when following a redirect. In order to test this behavior, this commit introduces the `readBodyMutationLogs` test utility function, along with the `window.bodyMutationLogs` property and the `BodyMutationLog` type. `BodyMutationLog` instances are pushed onto the log `Array` whenever the `<body>` element is replaced. [hotwired/turbo#794]: hotwired/turbo#794 [hotwired/turbo#674]: hotwired/turbo#674
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In a Rails app that I'm working on we have a (Capybara) system test that fails intermittently. The test looks something like this:
Sometimes the test fails because it can't find the text "The thing succeeded!". When inspecting the screenshot, the Capybara driver is stuck on the second page. The form field is empty and Chrome is showing it's built in "Please fill out this field." validation error. It looks as if the field was never filled in but the
fill_in
method never failed with a missing field error.I first tried adding
sleep
s in the test to see if there was a timing issue somewhere. I quickly found that adding a sleep before trying to fill in the field made the test pass consistently.After looking into many other things, I eventually tried changing the target of the link to point directly to the second page instead of the redirect, and the test passed consistently again!
This made me suspect that the redirect somehow affected Turbo's rendering so I tried adding a
console.log
inreplaceBody
and found that it was only called once (as expected) when linking directly to the second page but twice when following the redirect.The test was failing because it filled in the field after the first call to
replaceBody
but clicked the submit button after the second call, when the filled in field had been replaced with an empty one.In an attempt to fix this, I then tried adding back the
willRender: false
parameter to the call tovisitProposedToLocation
that was removed in 256418f—and the double render was gone! It also made the test that was added in 256418f fail, though, and I'm not sure how to fix it.I don't quite understand the change in 256418f but it seems to have been introduced to fix a somewhat unrelated issue? @seanpdoyle, do you think there is any chance we could achieve the same result without introducing a second call to
replaceBody
?The text was updated successfully, but these errors were encountered: