From 1d7002a63f50a868750d1465fd485eb921cf660d Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com> Date: Wed, 23 Sep 2020 23:12:22 -0400 Subject: [PATCH] Fix opening modals from other modals. (#2263) While seemingly correct, an onremove method in Modal that triggers animateHide is problematic, because if one modal is opened from another, the one currently open will be removed from the DOM, triggering animateHide, and closing the new modal. To compensate, an onupdate method now closes a modal if one is open but shouldn't be; this supports the functionality of the old method when the modal is closed not from the modal instance itself (e.g. app.modal.close()) This is not ideal, but necessary. We should consider eventually expanding the modal system to support showing multiple modals at the same time (stacked over each other). Then, we can move this back to individual modals. --- framework/core/js/src/common/components/Modal.js | 4 ---- framework/core/js/src/common/components/ModalManager.js | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/framework/core/js/src/common/components/Modal.js b/framework/core/js/src/common/components/Modal.js index 2a59beb01..b554b255e 100644 --- a/framework/core/js/src/common/components/Modal.js +++ b/framework/core/js/src/common/components/Modal.js @@ -27,10 +27,6 @@ export default class Modal extends Component { this.attrs.onshow(() => this.onready()); } - onremove() { - this.attrs.onhide(); - } - view() { if (this.alertAttrs) { this.alertAttrs.dismissible = false; diff --git a/framework/core/js/src/common/components/ModalManager.js b/framework/core/js/src/common/components/ModalManager.js index 35922f70d..8d13fe434 100644 --- a/framework/core/js/src/common/components/ModalManager.js +++ b/framework/core/js/src/common/components/ModalManager.js @@ -16,6 +16,12 @@ export default class ModalManager extends Component { ); } + onupdate() { + if (this.$('.Modal') && !this.attrs.state.modal) { + this.animateHide(); + } + } + oncreate(vnode) { super.oncreate(vnode);