Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/aria/private/tabs/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ export class TabListPattern {

/** Sets the default active state of the tablist before receiving interaction for the first time. */
setDefaultStateEffect(): void {
if (this.hasBeenInteracted()) return;
const activeTab = this.activeTab();
if (this.hasBeenInteracted() && activeTab && this.inputs.items().includes(activeTab)) return;

this.setDefaultState();
}
Expand Down
16 changes: 16 additions & 0 deletions src/aria/tabs/tabs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,22 @@ describe('Tabs', () => {
expect(testComponent.selectedTab()).toBeUndefined();
});

it('should make a remaining tab the Tab stop when the active tab is removed', async () => {
await click(tabElements[1]);
expect(isTabFocused(1)).toBe(true);

testComponent.tabsData.set([
{value: 'tab1', label: 'Tab 1', content: 'Content 1'},
{value: 'tab3', label: 'Tab 3', content: 'Content 3'},
]);
await fixture.whenStable();
defineTestVariables();

expect(isTabFocused(0)).toBe(true);
expect(tabElements[0].getAttribute('tabindex')).toBe('0');
expect(tabElements[1].getAttribute('tabindex')).toBe('-1');
});

it('should maintain selection when a new tab is added', async () => {
expect(testComponent.selectedTab()).toBe('tab2');

Expand Down
Loading