Skip to content

Commit

Permalink
feat(menu): prepare for Overlay v2 and less connnected/disconnected r…
Browse files Browse the repository at this point in the history
…esponsibilities
  • Loading branch information
Westbrook committed Aug 18, 2023
1 parent 56f7752 commit 5dfb71e
Show file tree
Hide file tree
Showing 10 changed files with 652 additions and 410 deletions.
263 changes: 190 additions & 73 deletions packages/menu/src/Menu.ts

Large diffs are not rendered by default.

17 changes: 5 additions & 12 deletions packages/menu/src/MenuGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,7 @@ export class MenuGroup extends Menu {
return [...super.styles, menuGroupStyles];
}

private static instances = 0;

private headerId!: string;

public constructor() {
super();
MenuGroup.instances += 1;
this.headerId = `sp-menu-group-label-${MenuGroup.instances}`;
}
private headerId = '';

@queryAssignedNodes({
slot: 'header',
Expand Down Expand Up @@ -75,6 +67,9 @@ export class MenuGroup extends Menu {
this.headerElement.removeAttribute('id');
}
if (headerElement) {
this.headerId =
this.headerId ||
`sp-menu-group-label-${crypto.randomUUID().slice(0, 8)}`;
const headerId = headerElement.id || this.headerId;
if (!headerElement.id) {
headerElement.id = headerId;
Expand All @@ -92,9 +87,7 @@ export class MenuGroup extends Menu {
<span class="header" ?hidden=${!this.headerElement}>
<slot name="header" @slotchange=${this.updateLabel}></slot>
</span>
<sp-menu ignore>
<slot></slot>
</sp-menu>
<sp-menu ignore>${this.renderMenuItemSlot()}</sp-menu>
`;
}
}
Loading

0 comments on commit 5dfb71e

Please sign in to comment.