Skip to content

Fix beforeunload dialog on save and add Playground support#17

Merged
erseco merged 4 commits intomainfrom
hotfix/fix-save-in-playground
Mar 31, 2026
Merged

Fix beforeunload dialog on save and add Playground support#17
erseco merged 4 commits intomainfrom
hotfix/fix-save-in-playground

Conversation

@erseco
Copy link
Copy Markdown
Contributor

@erseco erseco commented Mar 31, 2026

Summary

  • Fix "Leave site?" dialog: The eXeLearning editor registers a beforeunload event listener (via addEventListener) to prevent data loss. When closing the editor modal or saving to WordPress, this listener triggered the browser's native "Leave site?" confirmation dialog. Fixed by replacing the editor iframe with a fresh cloneNode() copy on close — this destroys all event listeners without navigating the iframe (which would trigger beforeunload). Also neutralizes onbeforeunload in the Gutenberg block preview iframe via Object.defineProperty.

  • Add make up-playground: New Makefile target to start wp-env with the WordPress Playground runtime (no Docker required). Useful for quick local testing and demos.

  • Add make reset: New Makefile target to reset the WordPress development database (wp-env reset development).

  • Update test fixture: Updated tests/fixtures/test-content.elpx to use the new eXeLearning resource path format (without legacy iDevice ID folders).

Test plan

  • Open editor, preview content, click "Save to WordPress" — no "Leave site?" dialog
  • Open editor, close it, click "Guardar" in WordPress post editor — no "Leave site?" dialog
  • Open editor, close it, open it again — editor loads correctly (no black screen)
  • Run make up-playground — WordPress starts without Docker
  • Run make reset — database is reset
  • Verify make up (Docker) still works as before

…xture

- Clear iframe beforeunload handler before closing the editor modal after
  saving to WordPress, preventing the browser's "Leave site?" confirmation
  dialog from appearing during the save flow.

- Add `make up-playground` target to start wp-env with the Playground
  runtime (no Docker required), useful for quick local testing.

- Add `make reset` target to reset the WordPress development database.

- Update test-content.elpx fixture to use the new eXeLearning resource
  path format (without legacy iDevice ID folders).
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 31, 2026

Test in WordPress Playground

Test the plugin with the code from this branch:

Preview in WordPress Playground

⚠️ The embedded eXeLearning editor is not included in this preview. You can install it from Settings > eXeLearning using the "Download & Install Editor" button. All other plugin features (ELP upload, shortcode, Gutenberg block, preview) work normally.

erseco added 3 commits March 31, 2026 08:35
This reverts commit 8b1f2f0.
…xture

- Fix "Leave site?" dialog: Replace the editor iframe with a fresh clone
  on close, destroying all event listeners (including the editor's
  beforeunload addEventListener) without triggering the browser dialog.
  Also neutralize onbeforeunload in the block preview iframe.

- Add `make up-playground` target to start wp-env with the Playground
  runtime (no Docker required), useful for quick local testing.

- Add `make reset` target to reset the WordPress development database.

- Update test-content.elpx fixture to use the new eXeLearning resource
  path format (without legacy iDevice ID folders).
@erseco erseco merged commit b92a8ee into main Mar 31, 2026
4 checks passed
@erseco erseco deleted the hotfix/fix-save-in-playground branch March 31, 2026 08:39
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.

1 participant