From 2e9ecad18b084a7e20011d395df4e99316a6e7d3 Mon Sep 17 00:00:00 2001 From: Brandon Marshall Date: Thu, 29 Jan 2026 12:51:47 -0800 Subject: [PATCH 1/2] fix: prevent plugin iframe blank on Library re-render --- blocks/edit/da-library/da-library.js | 52 ++++++++++-------- .../blocks/edit/da-library/da-library.test.js | 55 +++++++++++++++++++ 2 files changed, 84 insertions(+), 23 deletions(-) create mode 100644 test/unit/blocks/edit/da-library/da-library.test.js diff --git a/blocks/edit/da-library/da-library.js b/blocks/edit/da-library/da-library.js index 730b25f6b..e67fe1c00 100644 --- a/blocks/edit/da-library/da-library.js +++ b/blocks/edit/da-library/da-library.js @@ -8,6 +8,7 @@ import { createRef, ref, nothing, + repeat, } from 'da-lit'; import { getNx, sanitizePathParts } from '../../../scripts/utils.js'; import { getBlocks, getBlockVariants } from './helpers/index.js'; @@ -62,6 +63,7 @@ class DaLibrary extends LitElement { _blockPreviewPath: { state: true }, _previewItemName: { Type: String }, _previewStatus: { Type: Object }, + _activePane: { state: true }, }; constructor() { @@ -182,13 +184,12 @@ class DaLibrary extends LitElement { const toShow = this.shadowRoot.querySelector(`[data-library-type="${type}"]`); toShow.classList.remove('forward'); toShow.inert = false; - const pluginIframe = toShow.querySelector('iframe'); - if (!pluginIframe) return; - pluginIframe.src = pluginIframe.dataset.src; + this._activePane = type; } handleBack(e) { const { target } = e; + this._activePane = null; target.closest('.palette-pane').classList.add('forward'); target.closest('.palette-pane').inert = true; const wrapper = target.closest('.palette-wrapper'); @@ -199,6 +200,7 @@ class DaLibrary extends LitElement { handleCloseSearch() { this._searchStr = ''; + this._activePane = null; this.searchInputRef.value.value = ''; } @@ -383,7 +385,6 @@ class DaLibrary extends LitElement { @close=${this.handlePreviewClose}> ${status === 200 ? html`` : html`
${error || 'This block / template has not been previewed.'}
`} @@ -531,8 +532,7 @@ class DaLibrary extends LitElement { return html`
`; @@ -563,11 +563,7 @@ class DaLibrary extends LitElement { this._previewStatus = { ...this._previewStatus, ...status }; } - async renderLibrary({ name, sources, url, format, class: className }) { - const isPlugin = className.split(' ').some((val) => val === 'is-plugin'); - - if (isPlugin) return this.renderPlugin({ sources, url }); - + async renderLibrary({ name, sources, format }) { if (name === 'blocks') { if (!data.blocks) { data.blocks = await getBlocks(sources); @@ -616,12 +612,14 @@ class DaLibrary extends LitElement { renderMainMenu() { return html`