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.
This commit is contained in:
Alexander Skvortsov 2020-09-23 23:12:22 -04:00 committed by GitHub
parent 1ff4076f2a
commit 5b157f0adb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -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;

View File

@ -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);