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

Disable morphing per page #549

Open
morgoth opened this issue Jan 3, 2024 · 1 comment · May be fixed by #550
Open

Disable morphing per page #549

morgoth opened this issue Jan 3, 2024 · 1 comment · May be fixed by #550

Comments

@morgoth
Copy link
Contributor

morgoth commented Jan 3, 2024

Currently when setting turbo_refreshes_with(method: :morph, scroll: :preserve) in layout, it is set globally.

It's not easy to opt out of morphing on some single page. Duplicating meta tags via:

<% content_for(:head) do %>
  <%= turbo_refreshes_with(method: :replace, scroll: :reset) %>
<% end %>

does not work.

Even such combo doesn't work:
<%= content_for?(:morphing) ? yield(:morphing) : turbo_refreshes_with(method: :morph, scroll: :preserve) %>

<% content_for(:morphing) do %>
  <%= turbo_refreshes_with(method: :replace, scroll: :reset) %>
<% end %>

as the meta tags are cached between page navigation, so they cannot be overwritten this way.

Is there a nice way to do it? Maybe created meta tags should be marked with "data-turbo-track": "reload" so it's easier to change them between pages?

seanpdoyle added a commit to seanpdoyle/turbo-rails that referenced this issue Jan 3, 2024
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
@seanpdoyle seanpdoyle linked a pull request Jan 3, 2024 that will close this issue
@seanpdoyle
Copy link
Contributor

@morgoth thank you for opening this issue. I've opened #550 to implement the behavior you've described.

Unfortunately, no implementation changes were necessary to pass a JavaScript-enabled System Test that exercises the behavior as you've described. Could you provide some code review to help me reproduce the unexpected behavior you've experienced?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants