-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Content flashes on page revisit even with Turbolinks enabled #135
Comments
Hey, @bbugh. Thanks for opening an issue about this. About the 1. point on loading a spinner, did you try out an option for setting a placeholder from the docs? Not sure if that helps. What we do when you set the
So each time you visit a page, the |
Thanks for the reply. Yeah, I tried with and without placeholder and neither worked as expected, unfortunately. It sounds like the current behavior is that One possibility I thought of is to tag the top-level element of the sync loader with a Does this seem like a feature that the render_async code could readily support and/or want? |
Ah, I see now. Thanks for explaining in detail.
This sounds like a pretty cool feature we could add. What you described with the But, what I am worried about here is that we need to somehow tell Turbolinks to keep the previous "state" of loaded render_async. The original problem seems to be the flashing of the content on page revisit. This means that we need to cache contents of the loaded render_async somewhere on the frontend so it doesn't show the placeholder (maybe Turbolinks can do this for us with its preview functionality). I'd have to try this out to be sure. What would be extra helpful is if you can recreate your problem in a small Rails 6 + Turbolinks app. I have one here if you want to do it quickly. I could then play around with it and implement this feature. What do you think? |
Thanks for the reply! I will check out your sample project. Luckily, Turbolinks caches the page right before it draws a new one, not when it's first loaded, so it's correctly caching the content that
I believe that the only required change is to have some way to tell render_async not to remove existing content when it's been loaded once (as an option, presumably), like this matrix:
|
Awesome, thanks for providing all this info, it will be valuable for me. I will try to implement this as the next thing. If you find time to recreate a reproducible demo before I fix it, it will be even better. |
Hey, @bbugh, I investigated this issue a bit. Turns out that Turbolinks has 2 types of visits - the Application visit and the Restoration visit. It turns out that the Turbolinks does the following when you click a link (the Application visit):
But, if you try to do the following (the Restoration visit):
Everything is fine this way because what happened is a Restoration visit and it doesn't request the page from the server like the Application visit does. So, to sum up, there is not much here to do except to try to override what Turbolinks does, and that is not recommended in their README. Or we could try to save a previous response body, and wait for Anyway, I just wanted to give you an update and document what I found out so far. I might try to add such a feature, but right now it seems too complex. I will keep you posted. Please, let me know if you have any questions or suggestions. |
Hi! 👋 Very cool gem.
It's quite possible that I'm misunderstanding the intent, so this may not be a bug. Whenever I re-visit a Turbolinks page that has a
render_async
on it, the render_async runs again (which is great) resulting in an empty space or placeholder loading content (which is not ideal).The hope was for this particular sometimes slow-loading page that we could
This happens with
render_async
andrender_async_cache
.I made sure to follow the documentation closely, (set the turbolinks option in an initializer, the
content_for
is in the<head>
) but I can't seem to make this work with a fresh Rails 6.0.3.3. or 6.1rc1 app. Am I misunderstanding what should happen here or is this a bug?The text was updated successfully, but these errors were encountered: