Skip to content

Commit e329880

Browse files
committed
fix failing test by deferring computing selected tab index
1 parent 70590e0 commit e329880

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/tab-container-element.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,8 @@ export class TabContainerElement extends HTMLElement {
152152

153153
this.addEventListener('keydown', this)
154154
this.addEventListener('click', this)
155-
this.selectTab(
156-
Math.max(
157-
this.#tabs.findIndex(el => el.matches('[aria-selected=true]')),
158-
0,
159-
),
160-
)
155+
156+
this.selectTab(-1)
161157
this.#setupComplete = true
162158
}
163159

@@ -257,6 +253,8 @@ export class TabContainerElement extends HTMLElement {
257253
this.#beforeTabsSlot.assign(...beforeSlotted)
258254
this.#afterTabsSlot.assign(...afterTabSlotted)
259255
this.#afterPanelsSlot.assign(...afterSlotted)
256+
const defaultIndex = this.#tabs.findIndex(el => el.matches('[aria-selected=true]'))
257+
index = index >= 0 ? index : Math.max(0, defaultIndex)
260258
}
261259

262260
const tabs = this.#tabs

0 commit comments

Comments
 (0)