Fix beforeunload dialog on save and add Playground support#17
Merged
Conversation
…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).
Contributor
Test in WordPress PlaygroundTest the plugin with the code from this branch:
|
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix "Leave site?" dialog: The eXeLearning editor registers a
beforeunloadevent listener (viaaddEventListener) 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 freshcloneNode()copy on close — this destroys all event listeners without navigating the iframe (which would triggerbeforeunload). Also neutralizesonbeforeunloadin the Gutenberg block preview iframe viaObject.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.elpxto use the new eXeLearning resource path format (without legacy iDevice ID folders).Test plan
make up-playground— WordPress starts without Dockermake reset— database is resetmake up(Docker) still works as before