-
Notifications
You must be signed in to change notification settings - Fork 615
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
Handling beforeunload
with Partials enabled makes no effect
#2519
Comments
The browser only dispatches when "leaving" the page and a new full page load is happening. This is not the case with client-side routing as there is no full page load. We could dispatch an event when a new partial is requested, but there would still be some user code required to detect whether the partial is for the whole page or just a random small area on it. Fresh has no information what the partial in question represents. |
That makes sense, thank you very much! Is sending events when requesting or loading partials something already planned or tracked in another issue? |
Hello! First of all I want to send a huge "thank you" to everyone collaborating in this project.
While trying to handle the
beforeunload
event in an island (to show a confirmation dialog before the user leaves the page) I noticed that it didn't do anything. I finally noticed that it stopped working when enabling Partials in my app, so it seems that's the issue.Is this something expected when working with Partials? Is there a workaround that I can use to have Partials enabled handling the
beforeunload
event?Thank you very much!!
How to reproduce
I created a example repository with the minimal Fresh app handling the event to show a confirm dialog:
https://github.com/palpfiction/fresh-beforeunload-with-partials
The
main
branch doesn't use Partials and shows it working correctly when navigating. In the branchusing-partials
you can see that the confirm dialog doesn't show up anymore when navigating to the other page.The text was updated successfully, but these errors were encountered: