Skip to content

Give user alert to confirm browser refresh #81

Closed

Description

@hlashbrooke

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.

Activity

  1. akansjain commented on Jun 2, 2023

    @akansjain

    Hey @hlashbrooke ,
    Please assign this issue to me.

  2. adamziel commented on Jun 2, 2023

    @adamziel
    Collaborator

    @akansjain there you go!

  3. added a commit that references this issue on Aug 26, 2025
    c1e4cb6
  4. fellyph commented on Aug 27, 2025

    @fellyph
    Collaborator

    Thanks for sending us a PR @jnealey88, I will review it.

  5. iamsohilvahora commented on Jan 6, 2026

    @iamsohilvahora
    Contributor

    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:
    1. Refreshes the page
    2. Closes the tab
    3. 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 = '';
      });
  6. amannex commented on Apr 2, 2026

    @amannex

    Hi, I’d like to work on this issue. Can you assign it to me?

  7. mho22 commented on Jul 8, 2026

    @mho22
    Collaborator

    Closing this issue now that the Playground autosave feature has landed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions