From 2de53cdac770f12241bd24597fc0738420af1d7d Mon Sep 17 00:00:00 2001 From: Dave Lockhart Date: Fri, 17 Jan 2025 09:55:43 -0500 Subject: [PATCH] fix: additional waitForUpdateComplete in async dialogs --- components/dialog/dialog-mixin.js | 13 +++++++------ components/dialog/dialog.js | 7 ++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/components/dialog/dialog-mixin.js b/components/dialog/dialog-mixin.js index 29ddb04c3d7..02e02033921 100644 --- a/components/dialog/dialog-mixin.js +++ b/components/dialog/dialog-mixin.js @@ -149,6 +149,12 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) { }); } + async waitForUpdateComplete() { + const predicate = () => true; + const composedChildren = getComposedChildren(this, predicate); + await Promise.all(composedChildren.map(child => waitForElem(child, predicate))); + } + _addHandlers() { window.addEventListener('resize', this._updateSize); this.addEventListener('touchstart', this._handleTouchStart); @@ -455,7 +461,7 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) { const flag = window.D2L?.LP?.Web?.UI?.Flags.Flag('GAUD-7397-dialog-resize-update-complete', true) ?? true; if (flag) { - await this.#waitForUpdateComplete(); + await this.waitForUpdateComplete(); await this._updateSize(); } /** Dispatched when the dialog is opened */ @@ -587,9 +593,4 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) { }); } - async #waitForUpdateComplete() { - const predicate = () => true; - const composedChildren = getComposedChildren(this, predicate); - await Promise.all(composedChildren.map(child => waitForElem(child, predicate))); - } }; diff --git a/components/dialog/dialog.js b/components/dialog/dialog.js index 8110ec798ec..34864918091 100644 --- a/components/dialog/dialog.js +++ b/components/dialog/dialog.js @@ -205,7 +205,12 @@ class Dialog extends PropertyRequiredMixin(LocalizeCoreElement(AsyncContainerMix super.updated(changedProperties); if (!changedProperties.has('asyncState')) return; if (this.asyncState === asyncStates.complete) { - this.resize(); + const flag = window.D2L?.LP?.Web?.UI?.Flags.Flag('GAUD-7397-dialog-resize-update-complete', true) ?? true; + if (flag) { + this.waitForUpdateComplete().then(() => this.resize()); + } else { + this.resize(); + } } }