From 28056d0c0e5756d04cedf93eef067ca30b3d7896 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com> Date: Fri, 2 Oct 2020 11:12:49 -0400 Subject: [PATCH] Ensure that modal hide animates (#2332) We want to return a promise in``onbeforeremove` with arbitrary loading time to ensure that the animateHide animation has time to complete. --- framework/core/js/src/common/components/Modal.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/framework/core/js/src/common/components/Modal.js b/framework/core/js/src/common/components/Modal.js index 0d621060a..23338ee34 100644 --- a/framework/core/js/src/common/components/Modal.js +++ b/framework/core/js/src/common/components/Modal.js @@ -33,6 +33,9 @@ export default class Modal extends Component { // we don't need to show a hide animation. if (!this.attrs.state.modal) { this.attrs.animateHide(); + // Here, we ensure that the animation has time to complete. + // See https://mithril.js.org/lifecycle-methods.html#onbeforeremove + return new Promise((resolve) => setTimeout(resolve, 1000)); } }