Skip to content

Commit

Permalink
fix(esl-panel-group): fix event trowing when class target not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
ala-n committed Dec 23, 2021
1 parent a2a80d3 commit 4ad5e56
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/modules/esl-panel-group/core/esl-panel-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,19 @@ export class ESLPanelGroup extends ESLBaseElement {
/** Update element state according to current mode */
protected updateMode() {
const prevMode = this.getAttribute('view');
this.setAttribute('view', this.currentMode);
const currentMode = this.currentMode;
this.setAttribute('view', currentMode);

const $target = TraversingQuery.first(this.modeClsTarget, this);
if (!$target) return;
ESLPanelGroup.supportedModes.forEach((mode) => {
$target.classList.toggle(`esl-${mode}-view`, this.currentMode === mode);
$target && ESLPanelGroup.supportedModes.forEach((mode) => {
$target.classList.toggle(`esl-${mode}-view`, currentMode === mode);
});

this.reset();

this.$$fire('change:mode', {detail: {prevMode, currentMode: this.currentMode}});
if (prevMode !== currentMode) {
this.$$fire('change:mode', {detail: {prevMode, currentMode}});
}
}

/** @returns Panels that are processed by the current panel group */
Expand Down

0 comments on commit 4ad5e56

Please sign in to comment.