diff --git a/js/lib/components/ModalManager.js b/js/lib/components/ModalManager.js
index cc6bc08d7..81e3b78f5 100644
--- a/js/lib/components/ModalManager.js
+++ b/js/lib/components/ModalManager.js
@@ -7,6 +7,13 @@ import Modal from 'flarum/components/Modal';
* overwrite the previous one.
*/
export default class ModalManager extends Component {
+ constructor(...args) {
+ super(...args);
+
+ this.showing = false;
+ this.component = null;
+ }
+
view() {
return (
@@ -15,9 +22,11 @@ export default class ModalManager extends Component {
);
}
- config(isInitialized) {
+ config(isInitialized, context) {
if (isInitialized) return;
+ context.retain = true;
+
this.$()
.on('hidden.bs.modal', this.clear.bind(this))
.on('shown.bs.modal', this.onready.bind(this));
@@ -36,6 +45,7 @@ export default class ModalManager extends Component {
clearTimeout(this.hideTimeout);
+ this.showing = true;
this.component = component;
m.redraw(true);
@@ -50,12 +60,17 @@ export default class ModalManager extends Component {
* @public
*/
close() {
+ if (!this.showing) return;
+
// Don't hide the modal immediately, because if the consumer happens to call
// the `show` method straight after to show another modal dialog, it will
// cause Bootstrap's modal JS to misbehave. Instead we will wait for a tiny
// bit to give the `show` method the opportunity to prevent this from going
// ahead.
- this.hideTimeout = setTimeout(() => this.$().modal('hide'));
+ this.hideTimeout = setTimeout(() => {
+ this.$().modal('hide');
+ this.showing = false;
+ });
}
/**