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

Turbo Frame reload - no morphing possible? #1127

Open
coorasse opened this issue Jan 11, 2024 · 4 comments
Open

Turbo Frame reload - no morphing possible? #1127

coorasse opened this issue Jan 11, 2024 · 4 comments

Comments

@coorasse
Copy link
Contributor

I have some turbo frames that are eager/lazy loaded (i.e. they have a src attribute).
These frames can be reloaded.
The "problem" is that I cannot replace the content using idiomorph, but the frame content is always swapped with a new one.
I believe this is intentional or not planned at the moment, but I'd like to know if this is something that can/should be achieved differently.
Our need is basically to keep the "reloading" mechanism, but be able to swap the content using idiomorph.

@coorasse
Copy link
Contributor Author

I think what would be interesting would be also to have a "frame_refreshes" kind of feature.
Likewise the page_refreshes, but to signal clients that they should reload the frames.

@willcosgrove
Copy link
Contributor

willcosgrove commented Jan 24, 2024

@coorasse have you tried adding the refresh="morph" attribute on to your Turbo Frame? It looks like it is reloaded with a morph if it has that attribute:

#isFrameReloadedWithMorph(element) {
return element.src && element.refresh === "morph"
}

Here's the relevant commit with a message describing the feature: 9ff6e16

@krschacht
Copy link
Contributor

@coorasse and @willcosgrove I have this same issue, and I tried the solution that you proposed, Will. Unfortunately, it doesn't work. Specifically, I put refresh="morph" on my frame and then use a link to trigger: <a onclick="document.getElementById('frame').reload(); return false;" href="#">reload frame</a> and the frame reloads but it still re-writes the whole thing.

Based on reading the PR and testing it, it only does a morph of the frame when the full page is doing a morphing refresh. I just asked a clarifying question on the PR to see if this was an oversight:
#1068

In the meantime, I'm hunting for a workaround...

@seanpdoyle
Copy link
Contributor

Now that #1192 has been merged and FrameElement.reload() will utilize morphing when the [refresh="morph"] attribute is set, can this issue be resolved?

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

No branches or pull requests

4 participants