Skip to content

Commit

Permalink
fix: additional waitForUpdateComplete in async dialogs (#5325)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlockhart authored Jan 17, 2025
1 parent cb2daf5 commit 85814ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
13 changes: 7 additions & 6 deletions components/dialog/dialog-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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)));
}
};
7 changes: 6 additions & 1 deletion components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand Down

0 comments on commit 85814ef

Please sign in to comment.