summaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/popup-elements.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-28 20:45:50 -0400
committerGitHub <noreply@github.com>2020-10-28 20:45:50 -0400
commit890de095db4019e33bda4936dc32f85a8d99f20d (patch)
treea0edb28bc38ad7e870ccc6244366b0cdff9c0be4 /ext/bg/js/settings/popup-elements.js
parent25cedc8c524ddb5805a0686d1607c502426cdc14 (diff)
Fix modals not closing properly when the outside is clicked (#967)
Diffstat (limited to 'ext/bg/js/settings/popup-elements.js')
-rw-r--r--ext/bg/js/settings/popup-elements.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/ext/bg/js/settings/popup-elements.js b/ext/bg/js/settings/popup-elements.js
index 28f9883e..4b4a0e17 100644
--- a/ext/bg/js/settings/popup-elements.js
+++ b/ext/bg/js/settings/popup-elements.js
@@ -112,6 +112,32 @@ class Modal extends PopupElement {
closingClassName: 'modal-container-closing',
closingAnimationDuration: 375 // Milliseconds; includes buffer
});
+ this._canCloseOnClick = false;
+ }
+
+ prepare() {
+ const node = this._node;
+ node.addEventListener('mousedown', this._onModalContainerMouseDown.bind(this), false);
+ node.addEventListener('mouseup', this._onModalContainerMouseUp.bind(this), false);
+ node.addEventListener('click', this._onModalContainerClick.bind(this), false);
+ }
+
+ // Private
+
+ _onModalContainerMouseDown(e) {
+ this._canCloseOnClick = (e.currentTarget === e.target);
+ }
+
+ _onModalContainerMouseUp(e) {
+ if (!this._canCloseOnClick) { return; }
+ this._canCloseOnClick = (e.currentTarget === e.target);
+ }
+
+ _onModalContainerClick(e) {
+ if (!this._canCloseOnClick) { return; }
+ this._canCloseOnClick = false;
+ if (e.currentTarget !== e.target) { return; }
+ this.setVisible(false);
}
}