Skip to content

Commit a0caa22

Browse files
fix(tab-bar): handle an edge case in which there is no active tab (#1303)
1 parent 139aca2 commit a0caa22

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/elements/src/tab-bar/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,10 @@ export class TabBar extends BasicElement {
457457
const tabList = this.getFocusableTabs();
458458
if (tabList && tabList.length > 0) {
459459
const focusedTabIndex = tabList.findIndex((tab) => tab.active);
460-
this.rovingTabIndex(tabList[focusedTabIndex], tabList);
460+
// Handle an edge case in which there is no tab with truthy active prop.
461+
// There is a report that this happens on UI framework such as Angular.
462+
const safeIndex = Math.max(focusedTabIndex, 0);
463+
this.rovingTabIndex(tabList[safeIndex], tabList);
461464
}
462465
}
463466

0 commit comments

Comments
 (0)