Skip to content

Conversation

lindapaiste
Copy link
Collaborator

Fixes #2794
Discussion #2793

Changes:

  • Add back the beforeunload handler when closing the window with unsaved changes.

Notes:
This will be a native browser alert and we cannot control the message text (in modern browsers). See MDN. The styling will depend on the user's browser theme.

Screenshot 2023-12-27 15 43 48

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123

@lindapaiste lindapaiste requested a review from raclim December 27, 2023 21:45
@lindapaiste lindapaiste changed the title Show an alert when leaving site Show an alert when leaving site with unsaved changes Dec 27, 2023
Copy link
Contributor

@PiyushChandra17 PiyushChandra17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely Done 👍

@raclim raclim added this to the MINOR Release for 2.11.0 milestone Jan 8, 2024
// beforeunload handles closing or refreshing the window.
useEffect(() => {
const handleUnload = (e) => {
// See: https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event#browser_compatibility
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this, this is great! It would definitely be helpful to have more of these references/comments throughout the codebase!

@raclim raclim merged commit d961e49 into processing:develop Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing "are you sure?" alert when closing the window

3 participants