From e8febf394578bcb380481aff14cdc1faf78856e2 Mon Sep 17 00:00:00 2001 From: "ala'n (Alexey Stsefanovich)" Date: Thu, 22 Apr 2021 22:21:17 +0300 Subject: [PATCH] feat: extend ToggleableDispatcher params with more information --- .../core/esl-toggleable-dispatcher.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/modules/esl-toggleable/core/esl-toggleable-dispatcher.ts b/src/modules/esl-toggleable/core/esl-toggleable-dispatcher.ts index 4788dfd25..9bc600805 100644 --- a/src/modules/esl-toggleable/core/esl-toggleable-dispatcher.ts +++ b/src/modules/esl-toggleable/core/esl-toggleable-dispatcher.ts @@ -70,14 +70,20 @@ export class ESLToggleableDispatcher extends ESLBaseElement { } /** Hide active element in group */ - public hideActive(groupName: string) { - this.getActive(groupName)?.hide(); + public hideActive(groupName: string, activator?: HTMLElement) { + const active = this.getActive(groupName); + if (!active || active === activator) return; + active.hide({ + initiator: 'dispatcher', + dispatcher: this, + activator + }); } /** Set active element in group */ public setActive(groupName: string, popup: ESLToggleable) { if (!groupName) return; - this.hideActive(groupName); + this.hideActive(groupName, popup); this._popups.set(groupName, popup); } @@ -97,7 +103,7 @@ export class ESLToggleableDispatcher extends ESLBaseElement { protected _onBeforeShow(e: CustomEvent) { const target = EventUtils.source(e); if (!this.isAcceptable(target)) return; - this.hideActive(target.groupName); + this.hideActive(target.groupName, target); } /** Update active element after a new element is shown */