From e29e5f83cb5d3b56ab686d34ffaa991740564f58 Mon Sep 17 00:00:00 2001 From: bordun Date: Mon, 27 Jan 2020 09:27:49 +0100 Subject: [PATCH] menu: close when clicking outside in toggle mode --- src/client/app/widgets/buttons/menu.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/client/app/widgets/buttons/menu.js b/src/client/app/widgets/buttons/menu.js index 8bb7d291..6410a2a6 100644 --- a/src/client/app/widgets/buttons/menu.js +++ b/src/client/app/widgets/buttons/menu.js @@ -122,6 +122,11 @@ class Menu extends Widget { } else { this.menu.classList.add('norelease') + this.toggleCloseHandler = (e)=>{ + if (!this.opened || this.menu.contains(e.target)) return + this.close() + } + document.addEventListener('fast-click', this.toggleCloseHandler) } @@ -310,6 +315,15 @@ class Menu extends Widget { } + onRemove() { + + if (this.getProp('toggle')) { + document.removeEventListener('fast-click', this.toggleCloseHandler) + } + super.onRemove() + + } + } Menu.dynamicProps = Menu.prototype.constructor.dynamicProps.concat(