Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: additional waitForUpdateComplete in async dialogs #5325

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading