-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Handle back navigation from page without VT #7750
Conversation
🦋 Changeset detectedLatest commit: d2e9ab4 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
if (!transitionEnabledOnThisPage()) { | ||
// The current page doesn't haven't View Transitions, | ||
// respect that with a full page reload | ||
location.reload(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was unsure if this was the best way but from research it seems like it probably is? popstate is a weird API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that's fine
I am using htmx in an Astro component. Htmx does history management and can restore state when pressing the back button. However, the Astro popstate implementation reloads the page before Htmx gets an opportunity to do its work. I'm still investigating a solution, but I think that I might either need to trick Astro into not doing a reload (maybe just enable ViewTransitions), or somehow unregister the Astro popstate handler to prevent interference. @matthewp @ematipico What do you think would be a good approach to deal with this situation? Here is more information:
|
It turns out that I had |
For anyone looking to improve the onpopstate handling, here is a clip on the handler: https://youtu.be/javGxN-h9VQ?si=cYxRkzQnlO7Y9DGr&t=1080 |
Changes
location.reload()
so that a refresh is fired.Testing
Docs
N/A, bug fix