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

chore: add isUpdating flag to prevent multiple re-renders #4773

Closed
wants to merge 1 commit into from
Closed
Changes from all 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
10 changes: 10 additions & 0 deletions packages/overlay/src/OverlayTrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,17 @@ export class OverlayTrigger extends SpectrumElement {
this.targetContent = this.getAssignedElementsFromSlot(event.target);
}

private isUpdatingSlotContent = false;

private handleSlotContent(
event: Event & { target: HTMLSlotElement }
): void {
if (this.isUpdatingSlotContent) {
return;
}

this.isUpdatingSlotContent = true;

switch (event.target.name) {
case 'click-content':
this.clickContent = this.getAssignedElementsFromSlot(
Expand All @@ -130,6 +138,8 @@ export class OverlayTrigger extends SpectrumElement {
);
break;
}

this.isUpdatingSlotContent = false;
}

private handleBeforetoggle(event: BeforetoggleOpenEvent): void {
Expand Down
Loading