Skip to content

Commit

Permalink
await afterRender runloop queue
Browse files Browse the repository at this point in the history
  • Loading branch information
jelhan committed May 26, 2021
1 parent 88bfe6d commit 0899b2b
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions addon/components/bs-modal.js
Expand Up @@ -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.
Expand Down Expand Up @@ -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?.();
}

/**
Expand All @@ -478,7 +482,7 @@ export default class Modal extends Component {
await transitionEnd(this.modalElement, this.transitionDuration);
}

this.hideModal();
await this.hideModal();
}

/**
Expand Down

0 comments on commit 0899b2b

Please sign in to comment.