-
-
Notifications
You must be signed in to change notification settings - Fork 433
Hashchange causes full rerender of home route #536
Comments
Just to confirm, this bug still repros in Sapper 0.22.10. (I was hoping #484 would fix it.) |
My bad, I should have tested v0.25.0. After testing that version, it does appear that #484 makes the behavior uniform across all routes, although unfortunately in favor of a re-render, which is not what I would want for a modal dialog. 😞 In any case, I think this bug can be closed because the behavior is at least consistent now. I'm still not sure how to implement a modal that respects the back button in Sapper, though. |
I'm also not sure what the solution is but I agree that this is a problem, so I'm going to reopen this so we can revisit it after the Svelte 3 version (which takes a different approach to #484, but also wouldn't fix this) |
In nolanlawson@cb21193 I have a little hack I'm playing around with to see if it can work properly, but I have no idea if this is the right approach. Ideally I would like it to never re-render when the route is the same, but maybe this is because I'm not using |
FWIW I am working around this currently with nolanlawson@0780b25, but the change is pretty hacky, and also isn't compatible with the current Svelte@3 changes, so I didn't open a PR. |
Simple snippet to put in client.js to avoid this
Also i let you a store for window.location.hash, note that it will work in browser and fallback to an empty hash ("") in server
then you can do
|
Here is a better script handling mousewheel click and click with ctrlKey (opens in a new tab), contextmenu and focus for keyboard navigation I realised now that the strange behavior is because sapper puts a
|
I've been working on implementing modals in Pinafore that respect the browser back button (nolanlawson/pinafore#60). As it turns out, though, I think I've run into a bug in Sapper that makes this hard to implement.
Steps to repro:
/
)location.hash = '#my-modal'
)Expected result: the route doesn't re-render
Actual result: the route re-renders
Curiously, this only happens on the home route, not any other route. I've confirmed this by making a minimal repro in sapper-template.
If you open that demo, then open the console, then open the "modal," then press the back button, it calls
oncreate
for that route. But if you do the same on the "About" page, thenoncreate
is not called again.The text was updated successfully, but these errors were encountered: