modal.js: Don't try to hide a modal when there is none

Fixes a bug that when e.g. closing a color picker by clicking the escape key,
also the `modal.hide()` action is performed, even though there was no real modal
opened before, but it seems to react automatically on the escape key click.
This commit is contained in:
Yonas Habteab 2022-05-05 11:55:55 +02:00 committed by Johannes Meyer
parent 6d1d60c35d
commit a1cd7441c5
1 changed files with 4 additions and 1 deletions

View File

@ -171,7 +171,10 @@
var _this = event.data.self;
if (! event.isDefaultPrevented() && event.key === 'Escape') {
_this.hide(_this.$layout.children('#modal'));
let $modal = _this.$layout.children('#modal');
if ($modal.length) {
_this.hide($modal);
}
}
};