Skip to content

Commit

Permalink
feat: extend ToggleableDispatcher params with more information
Browse files Browse the repository at this point in the history
  • Loading branch information
ala-n committed Apr 22, 2021
1 parent 11306c4 commit e8febf3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/modules/esl-toggleable/core/esl-toggleable-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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 */
Expand Down

0 comments on commit e8febf3

Please sign in to comment.