From 0899b2be787426761bdc7283ad7c7ab74cf5a3aa Mon Sep 17 00:00:00 2001 From: Jeldrik Hanschke Date: Wed, 26 May 2021 17:34:46 +0200 Subject: [PATCH] await afterRender runloop queue --- addon/components/bs-modal.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/addon/components/bs-modal.js b/addon/components/bs-modal.js index 757921113..f2c56df13 100644 --- a/addon/components/bs-modal.js +++ b/addon/components/bs-modal.js @@ -16,6 +16,10 @@ function nextRunloop() { return new Promise((resolve) => next(resolve)); } +function afterRender() { + return new Promise((resolve) => schedule('afterRender', resolve)); +} + /** Component for creating [Bootstrap modals](http://getbootstrap.com/javascript/#modals) with custom markup. @@ -440,23 +444,23 @@ export default class Modal extends Component { this.checkScrollbar(); this.setScrollbar(); - schedule('afterRender', async () => { - let modalEl = this.modalElement; - if (!modalEl) { - return; - } + await afterRender(); + + const { modalElement } = this; + if (!modalElement) { + return; + } - modalEl.scrollTop = 0; - this.adjustDialog(); - this.showModal = true; - this.args.onShow?.(); + modalElement.scrollTop = 0; + this.adjustDialog(); + this.showModal = true; + this.args.onShow?.(); - if (this.usesTransition) { - await transitionEnd(this.modalElement, this.transitionDuration); - } + if (this.usesTransition) { + await transitionEnd(modalElement, this.transitionDuration); + } - this.args.onShown?.(); - }); + this.args.onShown?.(); } /** @@ -478,7 +482,7 @@ export default class Modal extends Component { await transitionEnd(this.modalElement, this.transitionDuration); } - this.hideModal(); + await this.hideModal(); } /**