Skip to content

Commit

Permalink
fix(navigation-secondary): unclosed slot tag (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
bennypowers committed Jun 1, 2023
1 parent 3290578 commit b5333ad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
4 changes: 4 additions & 0 deletions .changeset/rh-navigation-secondary-slot.md
@@ -0,0 +1,4 @@
---
"@rhds/elements": patch
---
`<rh-navigation-secondary>`: fix unclosed `cta` slot tag
56 changes: 28 additions & 28 deletions elements/rh-navigation-secondary/rh-navigation-secondary.ts
Expand Up @@ -154,12 +154,12 @@ export class RhNavigationSecondary extends LitElement {
<div id="container" part="container" class="${classMap({ expanded })}">
<slot name="logo" id="logo"></slot>
<button aria-controls="container"
aria-expanded="${String(expanded)}"
aria-expanded="${String(expanded) as 'true' | 'false'}"
@click="${this.#toggleMobileMenu}"><slot name="mobile-menu">Menu</slot></button>
<slot name="nav"></slot>
<div id="cta" part="cta">
<rh-context-provider color-palette="${ctaPalette}">
<slot name="cta"><slot>
<slot name="cta"></slot>
</rh-context-provider>
</div>
</div>
Expand All @@ -171,32 +171,6 @@ export class RhNavigationSecondary extends LitElement {
`;
}

/**
* Public API, opens a specific dropdown based on index.
* Closes all open dropdowns before opening specified.
* Toggles overlay to open
*/
open(index: number): void {
if (index == null) {
return;
}
const dropdown = this.#dropdownByIndex(index);
if (dropdown && RhNavigationSecondary.isDropdown(dropdown)) {
this.close();
this.#expand(index);
dropdown?.querySelector('a')?.focus();
this.overlayOpen = true;
}
}

/**
* Public API, closes all open dropdowns
*/
close(): void {
const dropdowns = this.#allDropdowns();
dropdowns.forEach(dropdown => this.#closeDropdown(dropdown));
}

/**
* When dropdown event is triggered gets dropdown index that triggered
* event then closes all dropdowns.
Expand Down Expand Up @@ -374,6 +348,32 @@ export class RhNavigationSecondary extends LitElement {
this.mobileMenuExpanded = !this.mobileMenuExpanded;
this.dispatchEvent(new SecondaryNavOverlayChangeEvent(this.mobileMenuExpanded, this));
}

/**
* Opens a specific dropdown based on index.
* Closes all open dropdowns before opening specified.
* Toggles overlay to open
*/
public open(index: number): void {
if (index != null) {
const dropdown = this.#dropdownByIndex(index);
if (dropdown && RhNavigationSecondary.isDropdown(dropdown)) {
this.close();
this.#expand(index);
dropdown?.querySelector('a')?.focus();
this.overlayOpen = true;
}
}
}

/**
* Closes all open dropdowns
*/
public close(): void {
this.#allDropdowns()
.forEach(dropdown =>
this.#closeDropdown(dropdown));
}
}

@customElement('rh-secondary-nav')
Expand Down

0 comments on commit b5333ad

Please sign in to comment.