From cc660fb6e09efa606104677457f30c5d0610ad7b Mon Sep 17 00:00:00 2001 From: Hannes Hertach Date: Wed, 15 Jul 2026 11:45:10 +0200 Subject: [PATCH 1/2] fix(ew-actions): flush collab writes before preview/publish Await forceSave() on before hitting AEM admin so the last ~2s of canvas edits (held in da-collab's debounce) aren't missed when AEM reads from da-admin. On flush failure, surface the same error dialog used for AEM errors instead of publishing stale content. Co-Authored-By: Claude Opus 4.7 (1M context) --- nx2/blocks/ew-actions/ew-actions.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/nx2/blocks/ew-actions/ew-actions.js b/nx2/blocks/ew-actions/ew-actions.js index d8a9d111..b7af8849 100644 --- a/nx2/blocks/ew-actions/ew-actions.js +++ b/nx2/blocks/ew-actions/ew-actions.js @@ -163,6 +163,30 @@ class NXEwActions extends LitElement { this._dialog = undefined; this._busy = true; + // Flush pending collab updates to da-admin before AEM reads it, + // otherwise the last ~2s of edits (held in da-collab's debounce) are missed. + const editorDoc = document.querySelector('ew-editor-doc'); + if (editorDoc?.forceSave) { + const flushResult = await editorDoc.forceSave(); + if (!flushResult?.ok) { + this._busy = false; + this._hasError = true; + this._dialog = { + phase: 'error', + error: { + action, + type: 'error', + message: flushResult?.error || 'Unable to confirm save. Please retry or reload the editor.', + }, + }; + await Promise.all([ + import('../shared/dialog/dialog.js'), + import(`${NX_BASE}/public/sl/components.js`), + ]); + return; + } + } + const result = await runAemPreviewOrPublish({ aemPath, action }); if (!result.ok) { await Promise.all([ From 3d2583313ec69c6251b5e7820aa8e83ebe00cea3 Mon Sep 17 00:00:00 2001 From: Hannes Hertach Date: Wed, 15 Jul 2026 15:02:35 +0200 Subject: [PATCH 2/2] fix(ew-actions): load dialog deps before setting error state Match the existing AEM-failure pattern: await the dialog + sl-button imports before assigning _dialog, so the reactive render doesn't briefly try to upgrade unregistered custom elements. Co-Authored-By: Claude Opus 4.7 (1M context) --- nx2/blocks/ew-actions/ew-actions.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nx2/blocks/ew-actions/ew-actions.js b/nx2/blocks/ew-actions/ew-actions.js index b7af8849..14fe603e 100644 --- a/nx2/blocks/ew-actions/ew-actions.js +++ b/nx2/blocks/ew-actions/ew-actions.js @@ -169,6 +169,10 @@ class NXEwActions extends LitElement { if (editorDoc?.forceSave) { const flushResult = await editorDoc.forceSave(); if (!flushResult?.ok) { + await Promise.all([ + import('../shared/dialog/dialog.js'), + import(`${NX_BASE}/public/sl/components.js`), + ]); this._busy = false; this._hasError = true; this._dialog = { @@ -179,10 +183,6 @@ class NXEwActions extends LitElement { message: flushResult?.error || 'Unable to confirm save. Please retry or reload the editor.', }, }; - await Promise.all([ - import('../shared/dialog/dialog.js'), - import(`${NX_BASE}/public/sl/components.js`), - ]); return; } }