From 867f8b6fc6247f209cd9b97b0eb833721aae9cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Fri, 19 Aug 2022 20:05:07 +0100 Subject: [PATCH] Window: Add a 'visible' property (to avoid re-showing closed windows) --- src/Window.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Window.js b/src/Window.js index 59ca371b..092f08d5 100644 --- a/src/Window.js +++ b/src/Window.js @@ -4,6 +4,7 @@ module.exports = class Window extends EventEmitter { constructor (options) { super() + this.visible = false this.dom = document.createElement('div') this.dom.className = 'Window' @@ -27,6 +28,8 @@ module.exports = class Window extends EventEmitter { dragElement(this.dom) this.dom.onclick = () => { + if (!this.visible) { return } + const activeEl = document.activeElement if (document.body.lastElementChild !== this.dom) { @@ -37,11 +40,13 @@ module.exports = class Window extends EventEmitter { } show () { + this.visible = true document.body.appendChild(this.dom) this.emit('show') } close () { + this.visible = false document.body.removeChild(this.dom) this.emit('close') }