From ebd182f7af8a7447fd07c6be305cf59223043b86 Mon Sep 17 00:00:00 2001 From: ABHISHEK KUMAR SINGH Date: Sat, 17 Oct 2026 05:26:37 +0000 Subject: [PATCH] fix(aria): restore tab stop when active tab is removed --- src/aria/private/tabs/tabs.ts | 3 ++- src/aria/tabs/tabs.spec.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/aria/private/tabs/tabs.ts b/src/aria/private/tabs/tabs.ts index 85a82d8496a1..6faab1626eb8 100644 --- a/src/aria/private/tabs/tabs.ts +++ b/src/aria/private/tabs/tabs.ts @@ -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(); } diff --git a/src/aria/tabs/tabs.spec.ts b/src/aria/tabs/tabs.spec.ts index 065677e040d1..1a56e792be03 100644 --- a/src/aria/tabs/tabs.spec.ts +++ b/src/aria/tabs/tabs.spec.ts @@ -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');