-
Notifications
You must be signed in to change notification settings - Fork 430
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
Bugfix: Redirects and [data-turbo-cache=false]
#674
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When redirecting to a page that contains elements marked with `[data-turbo-cache="false"]`, those elements are removed _before_ the initial render, instead of _after_ the render and _before_ the page is cached. This behavior seems to have stemmed from [hotwired#516][], which was shipped in response to [hotwired#515][]. As an alternative to the `willRender: false` option passed to `this.adapter.visitProposedToLocation` in `Visit.followRedirect`, the implementation can instead [rely on the presence of the `turbo-frame[complete]`][comment] to guard against double fetching. To guard against regressions, this commit adds coverage for the unwanted behavior by redirecting from `navigation.html` to `cache_observer.html`, and asserting the presence of a `[data-turbo-cache="false"]` element that resembles and application's Flash messaging. [hotwired#515]: hotwired#515 [hotwired#516]: hotwired#516 [comment]: hotwired#515 (comment) [hotwired#487]: hotwired#487
seanpdoyle
force-pushed
the
data-turbo-cache-bug
branch
from
August 9, 2022 16:15
4722714
to
7988314
Compare
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
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
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
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
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
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 pull request
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 pull request
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When redirecting to a page that contains elements marked with
[data-turbo-cache="false"]
, those elements are removed before theinitial render, instead of after the render and before the page is
cached.
This behavior seems to have stemmed from hotwired/turbo#516, which
was shipped in response to hotwired/turbo#515.
As an alternative to the
willRender: false
option passed tothis.adapter.visitProposedToLocation
inVisit.followRedirect
, theimplementation can instead rely on the presence of the
turbo-frame[complete]
to guard against double fetching.To guard against regressions, this commit adds coverage for the unwanted
behavior by redirecting from
navigation.html
tocache_observer.html
,and asserting the presence of a
[data-turbo-cache="false"]
elementthat resembles and application's Flash messaging.