Give user alert to confirm browser refresh
To prevent accidental page refreshes that will lose the user's data and progress, it would be great to have a basic browser alert that confirms if the user does want to refresh before it actually happens.
Hey @hlashbrooke , Please assign this issue to me.
@akansjain there you go!
Thanks for sending us a PR @jnealey88, I will review it.
Hi @hlashbrooke @fellyph ,
Please use below code to Prevents accidental data loss that works for local WordPress Playground (website)
What this does
- Shows a browser confirmation dialog when the user:
- Refreshes the page
- Closes the tab
- Navigates away
file path (WordPress Playground – local)
- packages/playground/website/src/main.tsx
Add this near the top, before React renders:
- window.addEventListener('beforeunload', (event) => { event.preventDefault(); event.returnValue = ''; });
Hi, I’d like to work on this issue. Can you assign it to me?
Closing this issue now that the Playground autosave feature has landed.