From fb2eb15738f2ead6f69640f69be83963deeab944 Mon Sep 17 00:00:00 2001 From: tito10047 Date: Sun, 22 Sep 2024 19:25:56 +0200 Subject: [PATCH 1/3] Add functionality to remove element from dom --- src/LiveComponent/assets/src/Component/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/LiveComponent/assets/src/Component/index.ts b/src/LiveComponent/assets/src/Component/index.ts index 18c6a5dea81..8e6b8b16e54 100644 --- a/src/LiveComponent/assets/src/Component/index.ts +++ b/src/LiveComponent/assets/src/Component/index.ts @@ -311,7 +311,8 @@ export default class Component { const headers = backendResponse.response.headers; if ( !headers.get('Content-Type')?.includes('application/vnd.live-component+html') && - !headers.get('X-Live-Redirect') + !headers.get('X-Live-Redirect') && + !headers.get('X-Live-Delete') ) { const controls = { displayError: true }; this.valueStore.pushPendingPropsBackToDirty(); @@ -366,6 +367,12 @@ export default class Component { return; } + if (backendResponse.response.headers.get('X-Live-Delete')) { + // action returned a delete element from the DOM + this.element.remove(); + + return; + } // remove the loading behavior now so that when we morphdom // "diffs" the elements, any loading differences will not cause From 758844809485b7edc1b156fc4f446ec29b820e13 Mon Sep 17 00:00:00 2001 From: tito10047 Date: Sun, 22 Sep 2024 19:38:20 +0200 Subject: [PATCH 2/3] add missing rebuild --- src/Autocomplete/assets/dist/controller.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Autocomplete/assets/dist/controller.js b/src/Autocomplete/assets/dist/controller.js index c6e9660b1d6..5dec346a52a 100644 --- a/src/Autocomplete/assets/dist/controller.js +++ b/src/Autocomplete/assets/dist/controller.js @@ -15,19 +15,12 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ -/* global Reflect, Promise, SuppressedError, Symbol */ - function __classPrivateFieldGet(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); -} - -typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { - var e = new Error(message); - return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; -}; +} var _default_1_instances, _default_1_getCommonConfig, _default_1_createAutocomplete, _default_1_createAutocompleteWithHtmlContents, _default_1_createAutocompleteWithRemoteData, _default_1_stripTags, _default_1_mergeObjects, _default_1_createTomSelect; class default_1 extends Controller { From 50430f495e8e26c5bb63f919afd0cac5cd4d5d04 Mon Sep 17 00:00:00 2001 From: tito10047 Date: Sun, 22 Sep 2024 19:38:29 +0200 Subject: [PATCH 3/3] add missing rebuild --- src/LiveComponent/assets/dist/live_controller.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/LiveComponent/assets/dist/live_controller.js b/src/LiveComponent/assets/dist/live_controller.js index 22b6b68f43a..f857171600d 100644 --- a/src/LiveComponent/assets/dist/live_controller.js +++ b/src/LiveComponent/assets/dist/live_controller.js @@ -1667,7 +1667,7 @@ class ElementChanges { element.classList.remove(...this.removedClasses); this.styleChanges.getChangedItems().forEach((change) => { element.style.setProperty(change.name, change.value); - return; + }); this.styleChanges.getRemovedItems().forEach((styleName) => { element.style.removeProperty(styleName); @@ -2040,7 +2040,8 @@ class Component { } const headers = backendResponse.response.headers; if (!headers.get('Content-Type')?.includes('application/vnd.live-component+html') && - !headers.get('X-Live-Redirect')) { + !headers.get('X-Live-Redirect') && + !headers.get('X-Live-Delete')) { const controls = { displayError: true }; this.valueStore.pushPendingPropsBackToDirty(); this.hooks.triggerHook('response:error', backendResponse, controls); @@ -2079,6 +2080,10 @@ class Component { } return; } + if (backendResponse.response.headers.get('X-Live-Delete')) { + this.element.remove(); + return; + } this.hooks.triggerHook('loading.state:finished', this.element); const modifiedModelValues = {}; Object.keys(this.valueStore.getDirtyProps()).forEach((modelName) => { @@ -2994,7 +2999,7 @@ class LiveControllerDefault extends Controller { }); validModifiers.set('self', () => { if (event.target !== event.currentTarget) { - return; + } }); validModifiers.set('debounce', (modifier) => {