Skip to content
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

Open
palpfiction opened this issue Jun 16, 2024 · 2 comments
Open

Handling beforeunload with Partials enabled makes no effect #2519

palpfiction opened this issue Jun 16, 2024 · 2 comments
Labels
feat New feature or request

Comments

@palpfiction
Copy link

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 branch using-partials you can see that the confirm dialog doesn't show up anymore when navigating to the other page.

@marvinhagemeister
Copy link
Collaborator

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.

@marvinhagemeister marvinhagemeister added the feat New feature or request label Jun 23, 2024
@palpfiction
Copy link
Author

That makes sense, thank you very much! Is sending events when requesting or loading partials something already planned or tracked in another issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants