Skip to content

fix(editor): show save errors and update nested or preview-less blocks after a save - #212

Merged
erseco merged 3 commits into
hotfix/editor-preview-fallback-in-canvas-iframefrom
hotfix/editor-save-feedback-and-nested-blocks
Nov 27, 2026
Merged

erseco merged 3 commits into
hotfix/editor-preview-fallback-in-canvas-iframefrom
hotfix/editor-save-feedback-and-nested-blocks

Conversation

@erseco

@erseco erseco commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #209 (same file); merge after #204 and #209. Four long-standing bugs in what the editor modal does after a save, found while reviewing #209.

A failed save showed nothing

The catch in handleExportFile() calls setSavingState( false ), which removes is-visible from the overlay, and then showLoadingError(), which only added is-error. The overlay is visibility: hidden without is-visible, so the message (e.g. "File too large") was written into a hidden element and the editor just stayed open. showLoadingError() now makes the overlay visible; its Close button already hides it.

A successful save could be reported as failed

updateBlockPreview() only checked wp.data. On a screen where another script loads wp-data without the block editor (Media Library, classic screens), select( 'core/block-editor' ) is undefined and .getBlocks() threw inside the save try: the file was stored, but no WP_SAVE_CONFIRMED was sent and the modal never closed. It now returns when the block editor store is missing.

Blocks inside a Group or Columns kept their old preview

getBlocks() returns the top level only, so a nested eXeLearning block was never updated and the post was not saved with the new URL. The walk now descends into innerBlocks.

A package that gained a preview kept "No preview available"

Only previewUrl was updated, while the block renders the iframe when hasPreview is also true. The save response carries a preview URL only when the package has one (build_save_response()), so the block now gets { previewUrl, hasPreview: true }.

Tests

  • New and updated JS tests for each case, failing before the change.
  • npm run test:js: 275 passed.
  • Not exercised in a browser.

Review follow-up

Making the error visible exposed what it said:

  • A non-JSON error page from the web server (413, 502) threw in response.json() and showed the parser's message; it now falls back to the save-failed text with the status.
  • WP_REQUEST_SAVE_ERROR (the export failing inside the editor iframe) only logged to the console; it now shows the error too.
  • The error overlay no longer keeps "Saving… Please wait" above the error, and the delayed hide scheduled by close() is cancelled when an error is shown.
  • The fallback text is no longer hard-coded English: it reuses the existing "Failed to save the file." string, already translated in every locale (catalogs regenerated; only the reference moved).
  • npm run test:js: 277 passed; make test: OK.

Not changed: updateBlockPreview() still calls savePost() after updating a block, which also publishes any unsaved edits of the post. That predates this PR and looks intentional, but it now applies to nested blocks as well.

@github-actions

Copy link
Copy Markdown
Contributor

Test in WordPress Playground

Test the plugin with the code from this branch:

Preview in WordPress Playground

ℹ️ The eXeLearning editor is fetched from the shared release and unpacked into the plugin when the playground boots, so the first load may take a few extra seconds. ELP upload, shortcode, Gutenberg block and preview work normally.

@codecov-commenter

codecov-commenter commented Nov 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.80%. Comparing base (83a20f1) to head (dad3801).

Additional details and impacted files
@@                                Coverage Diff                                 @@
##             hotfix/editor-preview-fallback-in-canvas-iframe     #212   +/-   ##
==================================================================================
  Coverage                                              96.79%   96.80%           
  Complexity                                               843      843           
==================================================================================
  Files                                                     37       37           
  Lines                                                   4334     4344   +10     
==================================================================================
+ Hits                                                    4195     4205   +10     
  Misses                                                   139      139           
Flag Coverage Δ
javascript 96.70% <100.00%> (+0.02%) ⬆️
php 96.83% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
assets/js/exelearning-editor.js 92.13% <100.00%> (+0.24%) ⬆️
includes/class-exelearning-editor.php 93.33% <100.00%> (+0.08%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 83a20f1...dad3801. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- A non-JSON error page (413, 502) shows the status instead of a parser error.
- An export error reported by the editor iframe is shown too.
- The error overlay hides its Saving title and message, and a pending hide no longer takes it away.
- The fallback text reuses the translated "Failed to save the file." string.
@erseco
erseco added this pull request to stack #213 November 27, 2026 19:59
…otfix/editor-save-feedback-and-nested-blocks
@erseco
erseco merged commit 3f0baba into main Nov 27, 2026
5 checks passed
@erseco
erseco deleted the hotfix/editor-save-feedback-and-nested-blocks branch November 27, 2026 20:17
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.

2 participants