-
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
Frames with loading lazy not working when src changes after restoration visit #886
Frames with loading lazy not working when src changes after restoration visit #886
Comments
@night91 yes, I can reproduce this. It does look like a bug to me. With markup like the following, the link stops working after a restoration visit: <body>
<turbo-frame id="frame" src="/frame1.html" loading="lazy"></turbo-frame>
<a href="/frame2.html" data-turbo-frame="frame">another frame</a>
</body> And as you say, the problem is only when Thanks for reporting! 🙏 |
Just ran into this issue, thought I might share my quick fix until things get ironed out in the library. Before the lazy loaded turbo-frame gets cached, remove the loading attribute but only if the frame is marked as complete. This allows frames that weren't yet lazy loaded to continue to function as expected.
|
I had a similar issue, this code that work for me: // Handles turbo bug with lazy loading
// https://github.com/hotwired/turbo/issues/886
document.addEventListener('turbo:load', () => {
document
.querySelectorAll('turbo-frame[loading="lazy"][complete]')
.forEach((frame) => frame.removeAttribute('loading'));
}); |
You are a legend @PedroAugustoRamalhoDuarte! Thanks for the fix. |
I have been having troubles with frames with lazy loading after a restoration visit. It doesn't load when src changes (using a link with a
data-turbo-frame
). Removing the lazy in the inspector, it makes the frame to work again.turbo/src/core/frames/frame_controller.ts
Line 116 in 4593d06
if (this.loadingStyle == FrameLoadingStyle.eager || this.hasBeenLoaded) {
I have been digging into the code and after a restoration visit the
loadSourceURL()
doesn't get called because of loading lazy and the status of thehasBeenLoaded
is false (lost value after the cache is loaded).I am not sure about this because I don't have the full scope. Can someone verify this?
Version: v7.3.0
The text was updated successfully, but these errors were encountered: