Skip to content

Commit

Permalink
fix(Modal): fix async callbacks throwing errors when component has al…
Browse files Browse the repository at this point in the history
…ready been destroyed. Thanks to @larsklevan.

Fixes #477
  • Loading branch information
larsklevan authored and simonihmig committed Nov 12, 2017
1 parent 3903ebb commit 5ffb806
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion addon/components/base/bs-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,11 @@ export default Component.extend(TransitionSupport, {
this.set('inDom', true);
schedule('afterRender', () => {
let modalEl = this.get('modalElement');
modalEl.scrollTop = 0;
if (!modalEl) {
return;
}

modalEl.scrollTop = 0;
this.handleUpdate();
this.set('showModal', true);
this.get('onShow')();
Expand Down Expand Up @@ -512,6 +515,9 @@ export default Component.extend(TransitionSupport, {
assert('Backdrop element should be in DOM', backdrop);

let callbackRemove = function() {
if (this.get('isDestroyed')) {
return;
}
this.set('showBackdrop', false);
if (callback) {
callback.call(this);
Expand Down

0 comments on commit 5ffb806

Please sign in to comment.