Skip to content

Commit

Permalink
fix(top-nav): initialize nav with an undefined selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook committed Nov 24, 2020
1 parent 6d19b20 commit d801d64
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/top-nav/src/TopNav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class TopNav extends SpectrumElement {
};

@property({ reflect: true })
public set selected(value: string) {
public set selected(value: string | undefined) {
const oldValue = this.selected;

if (value === oldValue) {
Expand All @@ -68,11 +68,11 @@ export class TopNav extends SpectrumElement {
this.requestUpdate('selected', oldValue);
}

public get selected(): string {
public get selected(): string | undefined {
return this._selected;
}

private _selected = '';
private _selected!: string | undefined;

protected items: TopNavItem[] = [];

Expand Down Expand Up @@ -122,13 +122,13 @@ export class TopNav extends SpectrumElement {
this.manageItems();
}

protected updateCheckedState(value: string): void {
protected updateCheckedState(value: string | undefined): void {
this.items.forEach((item) => {
item.selected = false;
});

requestAnimationFrame(() => {
if (value.length) {
if (value && value.length) {
const currentItem = this.items.find(
(item) =>
item.value === value ||
Expand Down

0 comments on commit d801d64

Please sign in to comment.