-
Notifications
You must be signed in to change notification settings - Fork 664
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
[BUG maybe] Website - Clicking the components in "Stream HTML straight from the server" writes an entire redirect to the back button cache #2797
Comments
That isn't actually the case, no. As such, Partials (and therefore that demo) aren't rerendering the page at all, it simply requests the recipe HTML from the server and swaps it in in-place, updating the history stack (and by extension the URL) accordingly to maintain navigation (bit unnecessary for this demo of course, but it's a good example). This is really easy to see from your browser's devtools, upon switching recipes only the relevant HTML is sent via the network, the rest of the page doesn't need to change. |
Is it then intentional that back button navigation/mouse bind takes me to a page that consists only of the miniaturized/rendered component? For instance navigating to this by direct pasting -
Will take me to a page that only consists of the new content? This may be the correct case here when navigating directly which means the provided path is working as intended. Clicking 'Lemonade' then back simply takes me back to the previous state which is correct. Refreshing the page to rese.
Hitting the back button will take me to a fullscreen page where the content of the page is only the below HTML: <html>
<head>
<meta charset="utf-8">
</head>
<body>
<h2 class="mb-2 font-extrabold">
Lemonade</h2>
<ul>
<li>
1 ¾ cups white sugar</li>
<li>
1 cup water</li>
<li>
9 lemons</li>
<li>
7 cups ice water</li>
<li>
Ice</li>
</ul>
<script type="module" nonce="dd873b60a0c2463eb7b2d5f3905e4496">
import { boot } from "/_fresh/js/8d8ec4eee3cadad8cd50fa7fe3b8757ad3756947/fresh-runtime.js";boot({},"[[]]");</script>
</body>
</html> This seems like odd behavior - at least from a first look/product showcase to take someone away from the website & branding. |
That bit does seem like a bug, yes. Blind guess, but |
Okay so I realized the actual code for the website is in this repo and I'm having a look through it - Clicking a single link, then back, then the next one in the element will not produce the bug. I will have a look around here: fresh/src/runtime/client/partials.ts Line 158 in 70d6cbd
(This was what came up with a quick repo search for popstate as you've mentioned) With the above behavior it seems to me we're only storing a single state change, calling the routing (and therefore only rendering the HTML) for the partial that was last created, when User is navigating back. |
First off, full disclosure: I work on Preact stuff and pop in here every now and then to see if Preact bugs are reported, maybe to help out when I can. I've never actually loaded up Fresh before (sorry Marvin!).
Unfortunately I think it does. It appears to me to be doing a full back nav to the page (though this isn't as problematic as you're going from Would have to look into it more (doing this from my phone, sorry!), but generally the Really good spot on this issue though. |
Ahh true, I'd not have guessed that you hadn't worked with Fresh directly haha. With Fresh seeming to be a fairly 'close-to' building block on top of Preact, I'm not surprised your blind guesses were right on point. fresh/src/runtime/client/partials.ts Lines 37 to 74 in 70d6cbd
fresh/src/runtime/client/partials.ts Lines 158 to 204 in 70d6cbd
The snippet above had me curious with the direct assignment of a/the state change - and your mention of a I've been able to re-produce this locally while running in dev (from root - |
Well none of this is actually related to Preact (or at least doesn't seem to be at the moment), just normal web API stuff. I've worked on some client-side routing stuff in the past though which is the source from my guesses. Will have to have a fiddle w/ it myself though. |
Considering the way the feature is worded it seems as though it should function similarly to something like a htm-x swap - I don't believe it should be rendering entire pages.
Interacting with the components for:
Lemonade,
Lemon-honey tea,
Lemondrop Martini
Do re-render the section of the page - but they also write an entry to the back and forward browser cache - meaning it's not swapping in-place but swapping the page.
Not sure if this is intended but would like to report it as it's a component of your website and therefore an on-boarding experience & brand name showcase type of thing.
Feel free to close this if its working as intended - otherwise it could be something that Preact itself is doing too, who knows.
The text was updated successfully, but these errors were encountered: