Skip to content
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

Update Turbo Drive <meta> across navigations #550

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seanpdoyle
Copy link
Contributor

Closes #549

Add System Test level coverage to ensure that Turbo Drive navigations will re-render any <meta> elements nested within the document's <head>.

To achieve this coverage, introduce the PagesController#show action that links to HTML pages that render their <head> based on the turbo_refresh_method and turbo_refresh_scroll query parameters.

@morgoth
Copy link
Contributor

morgoth commented Jan 4, 2024

@seanpdoyle Thank you for looking into this.

So I dig a bit more into it.
The behavior varies on tag placement.

<%= yield(:head) %>
<%= turbo_refreshes_with(method: :morph, scroll: :preserve) %>

does not work at all on first render. This is reasonable as the turbo_refreshes_with tries to write into head that was already yielded.

With layout:

<%= turbo_refreshes_with(method: :morph, scroll: :preserve) %>
<%= yield(:head) %>

And different page:

<%= turbo_refreshes_with(method: :replace, scroll: :reset) %>

I'm getting doubled tags when navigating from root page to the given page.

<meta name="turbo-refresh-method" content="morph">
<meta name="turbo-refresh-scroll" content="preserve">
...other head content...
<meta name="turbo-refresh-method" content="replace">
<meta name="turbo-refresh-scroll" content="reset">

and this seems to work properly as the behavior are taken from last tags on the page.

However when I enter the page directly (or refresh in the browser), I'm getting tags in such order:

<meta name="turbo-refresh-method" content="replace">
<meta name="turbo-refresh-scroll" content="reset">
<meta name="turbo-refresh-method" content="morph">
<meta name="turbo-refresh-scroll" content="preserve">

thus, it does not work as expected as the morphing is the last one.

BTW, I'm using turbo-rails 2.0.0.pre.beta.2 (from gem)

Closes [hotwired#549]

Add System Test level coverage to ensure that Turbo Drive navigations
will re-render any `<meta>` elements nested within the document's
`<head>`.

To achieve this coverage, introduce the `PagesController#show` action
that links to HTML pages that render their `<head>` based on the
`turbo_refresh_method` and `turbo_refresh_scroll` query parameters.

[hotwired#549]: hotwired#549
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.

Disable morphing per page
2 participants