Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(esl-toggleable): doesn't update after changing the activator #1679

Merged
merged 11 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/modules/esl-popup/core/esl-popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ export class ESLPopup extends ESLToggleable {
document.body.appendChild(this);
}

/** @returns whether the hide task should be executed for the open state during the show task executing */
protected override shouldHideIfOpen(params: ESLToggleableActionParams): boolean {
return params.activator !== this.activator;
}

/**
* Actions to execute on show popup.
* Inner state and 'open' attribute are not affected and updated before `onShow` execution.
Expand Down
9 changes: 8 additions & 1 deletion src/modules/esl-toggleable/core/esl-toggleable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,16 @@ export class ESLToggleable extends ESLBaseElement {
return this;
}

/** @returns whether the hide task should be executed for the open state during the show task executing */
protected shouldHideIfOpen(params: ESLToggleableActionParams): boolean {
return false;
}

/** Actual show task to execute by toggleable task manger ({@link DelayedTask} out of the box) */
protected showTask(params: ESLToggleableActionParams): void {
if (!params.force && this.open) return;
const shouldHide = this.shouldHideIfOpen(params);
if (!params.force && !shouldHide && this.open) return;
if (shouldHide && this.open) this.hideTask(params);
if (!params.silent && !this.$$fire(this.BEFORE_SHOW_EVENT, {detail: {params}})) return;
this.activator = params.activator;
this.open = true;
Expand Down