Skip to content

bug(aria/tabs): programmatic selectedTab change does not move the roving tab stop after user interaction #34182

Done

Description

@paul-gross

Is this a regression?

No

Description

In @angular/aria/tabs, when selectedTab on ngTabList is changed programmatically after the user has interacted with the tab list, the roving tab stop (tabindex="0") stays on the previously active tab. It does not move to the newly selected tab.

TabListPattern.setDefaultStateEffect() puts the active item on the selected tab only while hasBeenInteracted() is false. After a single click or keydown on the tab list it returns early. Nothing else in the public API moves the active item: TabList exposes selectedTab, open(value) and findTab(value), but no goto/active-item setter. The only way to fix the tab stop is to write tabList._pattern.inputs.activeItem directly.

This comes up whenever the selection is driven from outside the tab strip, for example by router state (browser Back/Forward), deep links, or a "jump to section" control elsewhere on the page.

The Listbox has the same gap in roving mode: gotoIndex() always calls element.focus(), so there is no public way to move the active item without taking focus.

Reproduction

@Component({
  imports: [Tabs, TabList, Tab, TabPanel, TabContent],
  template: `
    <div ngTabs>
      <div ngTabList [(selectedTab)]="selected">
        <div ngTab value="a">A</div>
        <div ngTab value="b">B</div>
        <div ngTab value="c">C</div>
      </div>
      <!-- panels omitted -->
    </div>
    <button (click)="selected.set('c')">Select C from outside</button>
  `,
})
export class Repro {
  readonly selected = signal<string | undefined>('a');
}
  1. Click tab B, which marks the list as interacted.
  2. Click Select C from outside.
  3. Press Shift+Tab or Tab to move focus back into the tab list.

Expected Behavior

Focus lands on tab C, the selected tab. The WAI-ARIA APG tabs pattern says that when focus moves into the tab list, it goes to the active tab element. After step 2, tab C has tabindex="0".

Actual Behavior

Focus lands on tab B. Tab B keeps tabindex="0", and the selected tab C has tabindex="-1".

Environment

  • Angular: 22.2.6
  • CDK/Material: @angular/aria 22.2.7
  • Browser(s): not browser-specific (state logic in TabListPattern)
  • Operating System (e.g. Windows, macOS, Ubuntu): any

A possible fix is to have the tab list re-sync activeItem to the selected tab whenever selectedTab changes and focus is not inside the list. Another is a public method to move the active item without focusing, such as a focusElement: false option on a public goto.

Activity

  1. self-assigned this
    on Nov 26, 2026
  2. added
    P3
    on Nov 26, 2026
  3. added 2 commits that reference this issue on Nov 26, 2026
    facee56
    5cedbdd
  4. added a commit that references this issue on Nov 26, 2026
    ef37d42
  5. added a commit that references this issue on Nov 26, 2026
    cabf210
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3area: aria/tabs

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions