Skip to content

fix(list): make selectable lists keyboard accessible - #18021

Open
adrianptrv wants to merge 8 commits into
masterfrom
apetrov/list-accessibility
Open

adrianptrv wants to merge 8 commits into
masterfrom
apetrov/list-accessibility

Conversation

@adrianptrv

@adrianptrv adrianptrv commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #17952

What changed

The new selectable input makes the list an accessible listbox. The list gets role="listbox", and:

  • Roles: items get role="option" with aria-selected.
  • Headers as group names: headers are hidden from screen readers and get an id when they have none. Each option points to the header above it with aria-describedby. An option's own aria-describedby, set or bound, is kept.
  • Tab: the list has a single tab stop. Tab focuses the option that was focused last, else the first selected one, else the first one, and the next Tab leaves the list. Headers and hidden items are skipped.
  • Arrow Up/Down, Home/End: move between options.
  • Enter/Space: act like a click, so (click) and itemClicked fire. Holding the key down clicks only once.
  • Loading: while isLoading is set, the list has aria-busy="true", and the loading message is hidden inside the listbox.
  • Focus ring: the focused option shows an inset ring on its content, also when it is selected. An empty or loading listbox shows the same ring on the list itself. Its color comes from the new item-focus-outline-color token, released in igniteui-theming 30.3.0
  • Screen readers:
    • When the focus moves into the list, it reads the list's label and the focused option content.
    • Moving to an option reads its content, its selected state, its position and its group.
    • Toggling an option with Enter/Space announces its new selected state.
  • Empty and loading lists. While the list has no options, the list itself is the tab stop, and its empty or loading message, the default or a custom template, is read as an option, like React Aria does. When options arrive while the list has the focus, the focus moves to them. While the list has options, the loading message is hidden from screen readers.

Lists that are not selectable are unchanged, including lists that only set role="listbox", like the grid's Excel-style filter list. The role input of the list is deprecated in favor of selectable, in its JSDoc and in the CHANGELOG.

Recommendations added to the README and CHANGELOG

  • Give the list a name with aria-label or aria-labelledby. Without one, some screen readers read the first item instead of the list.
  • Set aria-multiselectable="true" when more than one item can be selected. Otherwise screen readers treat the list as single-select and may not announce additional selections.
  • Avoid focusable controls inside items. To show the selection with a checkbox, make it inert and bind it to the item's state.

Type of Change (check all that apply):

  • New functionality
  • Demos
  • Tests
  • Changelog

Component(s) / Area(s) Affected:

List

How Has This Been Tested?

  • Unit tests
  • Manual testing

How to test

You can use the following example, or just open the list demo:

<igx-list selectable aria-label="Employees" aria-multiselectable="true">
  <igx-list-item [isHeader]="true">Team</igx-list-item>
  @for (item of items; track item.id) {
    <igx-list-item [selected]="item.selected" (click)="item.selected = !item.selected">
      {{ item.name }}
      <igx-checkbox igxListAction inert [checked]="item.selected"></igx-checkbox>
    </igx-list-item>
  }
</igx-list>
  1. Roles: inspect the items. They should be option with aria-selected.
  2. Group name: the header has an id and aria-hidden="true", and each option has aria-describedby pointing to it.
  3. Tab: Tab focuses the selected option (or the first one), and the next Tab leaves the list.
  4. Arrows: Up/Down move between options, and Home/End jump to the first/last option.
  5. Enter/Space: toggle the focused option. aria-selected and the checkbox follow.
  6. Focus ring: moving with the keyboard shows a ring on the focused option, also when it is selected.
  7. Screen reader: you can use macOS VoiceOver. When you Tab into the list, it should announce the aria-label text, the option's content, its selected state (if applicable), the group name and its position in the list.
  8. Static list: remove selectable. The list goes back to role="list", and its items aren't focusable.

Checklist:

  • All relevant labels have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

@adrianptrv
adrianptrv requested a review from simeonoff November 19, 2026 15:17
@adrianptrv adrianptrv added list ❌ status: awaiting-test PRs awaiting manual verification ♿ a11y When the issue or PR is related to accessibility keyboard-navigation a11y keyboard navigation related items labels Nov 19, 2026
Copilot AI balanced review requested due to automatic review settings November 19, 2026 15:17
@adrianptrv

Copy link
Copy Markdown
Contributor Author

@sdimchevski Because of the new listbox behavior, when navigating using only the keyboard, the first focus is on the list itself. On the next Tab press, the focus moves to the first item, then the second, and so on.

Currently, we don't have any visual indication that the list itself is focused before tabbing into the items. Should we add a border, outline, or some other visual cue to indicate when the list receives focus?

outline_list

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved accessibility issues hide keyboard focus, disrupt virtualized navigation and group descriptions, overwrite bound ARIA descriptions, and leave the demo listbox unnamed.

5 open issues
What changed in this PR

Addresses #17952 by adding keyboard navigation and selection semantics to Ignite UI for Angular lists whose items bind [selected], while preserving static-list behavior.

Changes:

  • Adds listbox/option roles, selection announcements, header-based descriptions, and keyboard navigation and activation.
  • Adds regression tests and fixtures for selectable lists and attribute handling.
  • Updates the demo, documentation, changelog, and selectable-item focus styling.
File Description
src/​app/​list/​list.sample.html Demonstrates item activation and inert selection checkboxes.
projects/​igniteui-angular/​test-utils/​list-components.spec.ts Adds selectable, grouped, and custom-attribute fixtures.
projects/​igniteui-angular/​list/​src/​list/​themes/​_base.scss Adjusts selectable-item focus styling.
projects/​igniteui-angular/​list/​src/​list/​list.component.ts Adds selectable-list roles, attribute synchronization, and keyboard handling.
projects/​igniteui-angular/​list/​src/​list/​list.component.spec.ts Tests roles, descriptions, navigation, activation, and static-list compatibility.
projects/​igniteui-angular/​list/​src/​list/​list.common.ts Tracks selection-bound items and provides attribute synchronization.
projects/​igniteui-angular/​list/​src/​list/​list-item.component.ts Adds option semantics, selection attributes, and group descriptions.
projects/​igniteui-angular/​list/​README.md Documents keyboard behavior and accessible usage.
CHANGELOG.md Records the behavioral changes and accessibility recommendations.

Review effort: Balanced

Comment thread src/app/list/list.sample.html Resolved

@simeonoff simeonoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrianptrv the keyboard handling and the README notes are a good base. I think a few things need to change before this goes in though, mostly around the tab order and how the mode gets turned on.

Every option is a tab stop. The list host gets tabindex="0" and so does every option (list-item.component.ts:321), so with 20 items Tab has to be pressed 21 times to leave the list. The listbox pattern expects a single tab stop, with the arrow keys moving inside it, which is also what #17952 asks for ("igx-list takes focus (or gets a roving tabindex on its items)"). Right now the arrow keys are an extra on top of Tab walking through everything.

Could we use a roving tabindex instead, like igx-tree does (tree-node.component.ts:97)? Only the active option gets tabindex="0", the rest get -1, and the list host isn't a tab stop at all. The active option is the one focused last, else the first selected one, else the first one, so Tab lands on the selection and Tab/Shift+Tab leave the list in one step. Your updateAttributes pass already has everything it needs for that:

const options = this.children.filter(item => item.list === this && !item.isHeader && !item.hidden);
const tabStop = options.includes(this._activeItem) ? this._activeItem
    : options.find(item => item.selected) ?? options[0];

with _activeItem updated from a focusin listener on the list. Since the focus is always on an option, the browser also scrolls it into view for us.

The mode turns on for every app that binds [selected]. Any [selected] binding, even [selected]="false", turns the list into a listbox with a tab stop per item. Apps that use [selected] only to style the current item get a different tab order and different screen reader output after updating, which is why the CHANGELOG has to list it as a behavioral change. #17952 suggests an opt-in ("through an opt-in input"), and I think we should do that. The role input is already there, so keying everything on role="listbox" needs no new API:

<igx-list role="listbox" aria-label="Employees">

That also removes selectionItems, the selectable getters and their override, and the role default that depends on them. I'd keep your afterEveryRender + syncAttribute approach though. I tried moving the attributes to host bindings first, but a host binding that returns null strips the attributes an app sets on a plain list, so your "keep the attributes set/bound by the app" specs fail. With the opt-in, the render pass returns right away for every list that isn't a listbox, so the cost only applies to lists that asked for it. syncAttribute can move out of IgxListBaseDirective into a plain function in list.common.ts, since it doesn't use the list.

One thing to keep in mind: apps that already set role="listbox" and manage tabindex/aria-selected themselves will have them taken over after updating. I think that's what they'd want, but it's worth a line in the CHANGELOG. If we'd rather not overload role, a dedicated boolean input works just as well with the same code.

The CHANGELOG entry then moves to New Features, and the commit becomes a feat(list): ... with the issue reference (CONTRIBUTING.md asks fix/feat commits to reference an issue).

Focus indicator. _base.scss:57-63 sets outline: none on focused options, so the only focus cue left is the :focus-within background, which is the same as hover. A focused option looks the same as a hovered one, and a focused selected option looks the same as any other selected one.

@sdimchevski what should a focused list item look like? The tree draws an inset ring on the focused node (box-shadow: inset 0 0 0 1px, 2px in Indigo) and keeps the hover and selected backgrounds as they are. If we do the same for the list, it would need a focus ring color token, because the list's border-color is the outer border of the whole list.

Group headers. I agree the headers need handling, because a listbox can only own options (and groups). But copying the header text into aria-description has a couple of problems:

  • aria-description is still a draft (ARIA 1.3), so support varies.
  • _ownDescription is read once in the constructor, so an app's [attr.aria-description] binding gets overwritten on the next render.
  • The text is copied, so it goes stale if the header text changes.

Since the DOM is flat we can't wrap items in role="group", but we can keep the headers aria-hidden, give each one an id when it doesn't have one, and point the options at it with aria-describedby. That's ARIA 1.2, it follows the header text on its own, and it works even though the header is hidden.

A few smaller things:

  • Holding Space fires the click on every key repeat. The diff ignores event.repeat but still prevents the default, so the list doesn't scroll. itemClicked.event is also a synthetic MouseEvent when triggered from the keyboard, which is worth a line in the README.
  • The keydown handler filters this.children (list.component.ts:575) instead of using items. items sorts by index, so if the two orders ever differ, the arrows move in a different order than items reports. The diff uses this.items.
  • While isLoading is true and items exist, the loading <article class="igx-list__message"> renders inside the listbox as a child that isn't an option. I didn't touch that in the diff. Can you decide how it should be exposed and cover it with a spec?
  • The demo keeps focusable <button igxListAction> controls inside the options (list.sample.html:39, :42), which goes against the README's own advice to avoid focusable controls in items. Either drop them or move the demo to the inert checkbox pattern from the README. The demo, README and CHANGELOG also need role="listbox" once it's opt-in.
  • skills/igniteui-angular-components/references/data-display.md should mention the listbox mode, so agents set role="listbox" and aria-label when they generate a selectable list.

Here's a diff against your branch with these changes:

Source changes (against apetrov/list-accessibility)
diff --git a/projects/igniteui-angular/list/src/list/list-item.component.ts b/projects/igniteui-angular/list/src/list/list-item.component.ts
index ddeefec8fe..352667a4f3 100644
--- a/projects/igniteui-angular/list/src/list/list-item.component.ts
+++ b/projects/igniteui-angular/list/src/list/list-item.component.ts
@@ -3,12 +3,15 @@ import { ChangeDetectionStrategy, Component, ElementRef, HostBinding, HostListen
 import {
     IgxListPanState,
     IListChild,
-    IgxListBaseDirective
+    IgxListBaseDirective,
+    syncAttribute
 } from './list.common';
 
 import { rem, IgxTouchManager, IgxGestureEvent } from 'igniteui-angular/core';
 import { NgTemplateOutlet } from '@angular/common';
 
+let NEXT_HEADER_ID = 0;
+
 /**
  * The Ignite UI List Item component is a container intended for row items in the Ignite UI for Angular List component.
  *
@@ -40,8 +43,8 @@ export class IgxListItemComponent implements IListChild, OnInit, OnDestroy {
      */
     private _gestures: IgxTouchManager | null = null;
 
-    /** The `aria-description` set on the item in the template, which is kept instead of the group name. */
-    private readonly _ownDescription = this.elementRef.nativeElement.getAttribute('aria-description');
+    /** The `aria-describedby` set on the item in the template, which is kept instead of the group header. */
+    private readonly _ownDescribedBy = this.elementRef.nativeElement.getAttribute('aria-describedby');
 
     /**
      * Provides a reference to the template's base element shown when left panning a list item.
@@ -261,7 +264,7 @@ export class IgxListItemComponent implements IListChild, OnInit, OnDestroy {
 
     /**
      * Gets/Sets the `role` attribute of the `list item`.
-     * Defaults to `separator` for headers, and for items to `option` when the items of the list bind `selected`
+     * Defaults to `separator` for headers, and for items to `option` in a list with `role="listbox"`
      * and to `listitem` otherwise.
      * ```typescript
      * let itemRole =  this.listItem.role;
@@ -272,7 +275,7 @@ export class IgxListItemComponent implements IListChild, OnInit, OnDestroy {
     @HostBinding('attr.role')
     @Input()
     public get role() {
-        return this._role ? this._role : this.isHeader ? 'separator' : this.list.selectable ? 'option' : 'listitem';
+        return this._role ? this._role : this.isHeader ? 'separator' : this.list.isListbox ? 'option' : 'listitem';
     }
 
     public set role(val: string) {
@@ -306,23 +309,28 @@ export class IgxListItemComponent implements IListChild, OnInit, OnDestroy {
 
     public set selected(value: boolean) {
         this._selected = value;
-        this.list.selectionItems.add(this);
     }
 
     /**
      * @hidden
      * @internal
-     * In a list whose items bind `selected`, the options are tab stops that expose their selected state
-     * and are described by the header of their group, unless they have their own `aria-description`.
-     * The headers are hidden from assistive technology. Called by the list after rendering.
-     */
-    public updateAttributes(selectable: boolean, header: IgxListItemComponent | null) {
-        const option = selectable && !this.isHeader;
-        this.list.syncAttribute(this.element, 'tabindex', option ? '0' : null);
-        this.list.syncAttribute(this.element, 'aria-selected', option ? String(this.selected) : null);
-        this.list.syncAttribute(this.element, 'aria-hidden', selectable && this.isHeader ? 'true' : null);
-        if (!this._ownDescription) {
-            this.list.syncAttribute(this.element, 'aria-description', (option && header?.element.textContent.trim()) || null);
+     * Syncs the listbox attributes of the item. Options expose their selected state, only the active one is a tab stop,
+     * and they are described by the header of their group. Headers are hidden from assistive technology.
+     *
+     * @param listbox Whether the list is a listbox.
+     * @param tabStop Whether the item is the active option.
+     * @param header The header of the item's group.
+     */
+    public updateAttributes(listbox: boolean, tabStop: boolean, header: IgxListItemComponent | null) {
+        const option = listbox && !this.isHeader;
+        syncAttribute(this.element, 'tabindex', option ? (tabStop ? '0' : '-1') : null);
+        syncAttribute(this.element, 'aria-selected', option ? String(this.selected) : null);
+        syncAttribute(this.element, 'aria-hidden', listbox && this.isHeader ? 'true' : null);
+        if (listbox && this.isHeader && !this.element.id) {
+            this.element.id = `igx-list-header-${NEXT_HEADER_ID++}`;
+        }
+        if (!this._ownDescribedBy) {
+            syncAttribute(this.element, 'aria-describedby', (option && header?.element.id) || null);
         }
     }
 
@@ -394,7 +402,6 @@ export class IgxListItemComponent implements IListChild, OnInit, OnDestroy {
      */
     public ngOnDestroy() {
         this._gestures?.destroy();
-        this.list.selectionItems.delete(this);
     }
 
     /**
diff --git a/projects/igniteui-angular/list/src/list/list.common.ts b/projects/igniteui-angular/list/src/list/list.common.ts
index ea69407ae7..76798cbe84 100644
--- a/projects/igniteui-angular/list/src/list/list.common.ts
+++ b/projects/igniteui-angular/list/src/list/list.common.ts
@@ -26,42 +26,24 @@ export class IgxListBaseDirective {
     public listItemLeftPanningTemplate!: IgxListItemLeftPanningTemplateDirective;
     public listItemRightPanningTemplate!: IgxListItemRightPanningTemplateDirective;
 
-    /**
-     * @hidden
-     * @internal
-     * The items that bind `selected`.
-     */
-    public readonly selectionItems = new Set<{ isHeader: boolean }>();
-
-    /**
-     * @hidden
-     * @internal
-     * Whether an item that is not a header binds `selected`.
-     * Such a list follows the ARIA listbox pattern.
-     */
-    public get selectable(): boolean {
-        for (const item of this.selectionItems) {
-            if (!item.isHeader) {
-                return true;
-            }
-        }
+    /** @hidden @internal Whether the list follows the ARIA listbox pattern. */
+    public get isListbox(): boolean {
         return false;
     }
+}
 
-    /**
-     * @hidden
-     * @internal
-     * Sets or removes (with `null`) an attribute of the list or one of its items, when it changes.
-     */
-    public syncAttribute(element: Element, name: string, value: string | null) {
-        if (element.getAttribute(name) === value) {
-            return;
-        }
-        if (value === null) {
-            element.removeAttribute(name);
-        } else {
-            element.setAttribute(name, value);
-        }
+/**
+ * @hidden
+ * Sets an attribute, or removes it with `null`, only when its value changes.
+ */
+export function syncAttribute(element: Element, name: string, value: string | null) {
+    if (element.getAttribute(name) === value) {
+        return;
+    }
+    if (value === null) {
+        element.removeAttribute(name);
+    } else {
+        element.setAttribute(name, value);
     }
 }
 
diff --git a/projects/igniteui-angular/list/src/list/list.component.ts b/projects/igniteui-angular/list/src/list/list.component.ts
index 0a5b1770e3..4028b0a76c 100644
--- a/projects/igniteui-angular/list/src/list/list.component.ts
+++ b/projects/igniteui-angular/list/src/list/list.component.ts
@@ -499,48 +499,53 @@ export class IgxListComponent extends IgxListBaseDirective {
         return null!;
     }
 
-    /** Whether the list has been selectable, so its attributes and those of its items are kept in sync. */
+    /** Whether the list has been a listbox, so its items are reset when it stops being one. */
     private _synced = false;
 
+    /** The option that was focused last, which keeps the tab stop. */
+    private _activeItem: IgxListItemComponent | null = null;
+
     /**
-     * A list whose items bind `selected` is a tab stop, and so are its options.
-     * A list that has never been selectable and its items are left untouched.
+     * Syncs the listbox attributes of the items. Only the active option is a tab stop: the one focused last,
+     * else the first selected option, else the first option. A list that has never been a listbox is left untouched.
      */
     private updateAttributes() {
-        const selectable = this.selectable;
-        if (!selectable && !this._synced) {
+        const listbox = this.isListbox;
+        if (!listbox && !this._synced) {
             return;
         }
-        this._synced = true;
-        this.syncAttribute(this.element.nativeElement, 'tabindex', selectable ? '0' : null);
+        this._synced = listbox;
+        const options = this.children.filter(item => item.list === this && !item.isHeader && !item.hidden);
+        const tabStop = options.includes(this._activeItem!) ? this._activeItem
+            : options.find(item => item.selected) ?? options[0];
         let header: IgxListItemComponent | null = null;
         for (const item of this.children) {
             if (item.list === this) {
                 header = item.isHeader ? item : header;
-                item.updateAttributes(selectable, header);
+                item.updateAttributes(listbox, item === tabStop, header);
             }
         }
     }
 
-    /** The role set by the app. While not set, the role depends on whether the list is selectable. */
-    private _role: string | undefined;
+    private _role = 'list';
 
     /**
      * Gets/Sets the `role` attribute value.
      *
      * @remarks
-     * Defaults to `listbox` when its items bind `selected` and to `list` otherwise.
-     * Setting a role other than `listbox` turns off the listbox roles, the focus and the keyboard navigation of the list and its items.
+     * Set it to `listbox` to make the list follow the ARIA listbox pattern: its items become options that expose
+     * their `selected` state, Tab focuses the selected option, Arrow Up/Down and Home/End move between the options,
+     * and Enter/Space click the focused option.
      *
      * @example
-     * ```typescript
-     * let listRole =  this.list.role;
+     * ```html
+     * <igx-list role="listbox" aria-label="Employees">
      * ```
      */
     @HostBinding('attr.role')
     @Input()
     public get role() {
-        return this._role !== undefined ? this._role : this.selectable ? 'listbox' : 'list';
+        return this._role;
     }
 
     public set role(val: string) {
@@ -550,38 +555,42 @@ export class IgxListComponent extends IgxListBaseDirective {
     /**
      * @hidden
      * @internal
-     * Whether the list follows the ARIA listbox pattern: an item that is not a header binds `selected`,
-     * and no role other than `listbox` is set on the list.
      */
-    @HostBinding('class.igx-list--selectable')
-    public override get selectable(): boolean {
-        return (this._role === undefined || this._role === 'listbox') && super.selectable;
+    @HostBinding('class.igx-list--listbox')
+    public override get isListbox(): boolean {
+        return this._role === 'listbox';
+    }
+
+    /** @hidden @internal */
+    @HostListener('focusin', ['$event'])
+    public onFocusIn(event: FocusEvent) {
+        const item = this.children.find(i => i.list === this && !i.isHeader && i.element === event.target);
+        this._activeItem = item ?? this._activeItem;
     }
 
     /**
      * @hidden
      * @internal
-     * Moves the focus between the items of a list whose items bind `selected`.
-     * ArrowDown/ArrowUp go to the next/previous item, Home/End to the first/last one.
-     * Enter/Space activate the focused item like a click, so `itemClicked` and its `click` handlers fire.
-     * Keys pressed in the content of an item are not handled.
+     * Moves the focus between the options of a listbox and clicks the focused option with Enter/Space.
+     *
+     * @param event The keydown event that bubbled up from an option.
      */
     @HostListener('keydown', ['$event'])
     public onKeydown(event: KeyboardEvent) {
-        if (!this.selectable) {
+        if (!this.isListbox) {
             return;
         }
 
-        const items = this.children.filter(item => item.list === this && !item.isHeader && !item.hidden);
-        const current = items.findIndex(item => item.element === event.target);
-        if (current === -1 && event.target !== this.element.nativeElement) {
+        const options = this.items.filter(item => item.list === this && !item.hidden);
+        const current = options.findIndex(item => item.element === event.target);
+        if (current === -1) {
             return;
         }
 
         if (event.key === 'Enter' || event.key === ' ') {
-            if (current !== -1) {
-                event.preventDefault();
-                items[current].element.click();
+            event.preventDefault();
+            if (!event.repeat) {
+                options[current].element.click();
             }
             return;
         }
@@ -589,23 +598,23 @@ export class IgxListComponent extends IgxListBaseDirective {
         let next: number;
         switch (event.key) {
             case 'ArrowDown':
-                next = Math.min(current + 1, items.length - 1);
+                next = Math.min(current + 1, options.length - 1);
                 break;
             case 'ArrowUp':
-                next = current === -1 ? items.length - 1 : Math.max(current - 1, 0);
+                next = Math.max(current - 1, 0);
                 break;
             case 'Home':
                 next = 0;
                 break;
             case 'End':
-                next = items.length - 1;
+                next = options.length - 1;
                 break;
             default:
                 return;
         }
 
         event.preventDefault();
-        items[next]?.element.focus();
+        options[next].element.focus();
     }
 
     /**
Spec changes
diff --git a/projects/igniteui-angular/list/src/list/list.component.spec.ts b/projects/igniteui-angular/list/src/list/list.component.spec.ts
index 44b5f58dc5..41b7324874 100644
--- a/projects/igniteui-angular/list/src/list/list.component.spec.ts
+++ b/projects/igniteui-angular/list/src/list/list.component.spec.ts
@@ -762,15 +762,16 @@ describe('List', () => {
         expect(headerItem.element.classList.contains('igx-list__item-base--selected')).toBe(false);
     });
 
-    describe('Selectable list', () => {
+    describe('Listbox', () => {
         let fixture: ComponentFixture<SelectableListComponent>;
         let list: IgxListComponent;
 
-        const pressKey = (target: HTMLElement, key: string): KeyboardEvent => {
-            const event = new KeyboardEvent('keydown', { key, bubbles: true, cancelable: true });
+        const pressKey = (target: HTMLElement, key: string, repeat = false): KeyboardEvent => {
+            const event = new KeyboardEvent('keydown', { key, repeat, bubbles: true, cancelable: true });
             target.dispatchEvent(event);
             return event;
         };
+        const tabIndexes = () => list.items.map(i => i.element.getAttribute('tabindex'));
 
         beforeEach(() => {
             fixture = TestBed.createComponent(SelectableListComponent);
@@ -778,7 +779,7 @@ describe('List', () => {
             fixture.detectChanges();
         });
 
-        it('should keep the attributes set by the app when no item binds selected', () => {
+        it('should keep the attributes set by the app when the list is not a listbox', () => {
             const ownFixture = TestBed.createComponent(ListWithOwnAttributesComponent);
             ownFixture.detectChanges();
             const ownList = ownFixture.componentInstance.list;
@@ -790,7 +791,7 @@ describe('List', () => {
             expect(item.element.getAttribute('aria-selected')).toBe('true');
         });
 
-        it('should keep the attributes bound by the app when no item binds selected', () => {
+        it('should keep the attributes bound by the app when the list is not a listbox', () => {
             const boundFixture = TestBed.createComponent(ListWithBoundAttributesComponent);
             boundFixture.detectChanges();
             const boundList = boundFixture.componentInstance.list;
@@ -800,92 +801,101 @@ describe('List', () => {
             expect(header.element.getAttribute('aria-hidden')).toBe('true');
             expect(item.element.getAttribute('tabindex')).toBe('0');
             expect(item.element.getAttribute('aria-selected')).toBe('true');
-            expect(item.element.getAttribute('aria-description')).toBe('Note');
 
             boundFixture.componentInstance.tabIndex = '-1';
             boundFixture.componentInstance.selected = 'false';
             boundFixture.detectChanges();
-            expect(boundList.element.nativeElement.getAttribute('tabindex')).toBe('-1');
             expect(item.element.getAttribute('tabindex')).toBe('-1');
             expect(item.element.getAttribute('aria-selected')).toBe('false');
         });
 
-        it('should leave a list whose items do not bind selected unchanged', () => {
-            const plainFixture = TestBed.createComponent(ListWithHeaderComponent);
+        it('should leave a list that binds selected but is not a listbox unchanged', () => {
+            const plainFixture = TestBed.createComponent(ListWithSelectedItemComponent);
             plainFixture.detectChanges();
             const plainList = plainFixture.componentInstance.list;
             const listElement = plainList.element.nativeElement as HTMLElement;
 
             expect(listElement.getAttribute('role')).toBe('list');
             expect(listElement.hasAttribute('tabindex')).toBe(false);
-            plainList.headers.forEach(header => {
-                expect(header.element.getAttribute('role')).toBe('separator');
-                expect(header.element.hasAttribute('aria-hidden')).toBe(false);
-            });
             plainList.items.forEach(item => {
                 expect(item.element.getAttribute('role')).toBe('listitem');
                 expect(item.element.hasAttribute('tabindex')).toBe(false);
                 expect(item.element.hasAttribute('aria-selected')).toBe(false);
-                expect(item.element.hasAttribute('aria-description')).toBe(false);
             });
             expect(pressKey(plainList.items[0].element, 'ArrowDown').defaultPrevented).toBe(false);
         });
 
-        it('should be a focusable listbox with option items that expose their selected state', () => {
+        it('should expose option roles and selected state, with a single tab stop on the selected option', () => {
             const listElement = list.element.nativeElement as HTMLElement;
             const [header, ...items] = list.children.toArray();
 
             expect(listElement.getAttribute('role')).toBe('listbox');
-            expect(listElement.getAttribute('tabindex')).toBe('0');
-            expect(header.element.getAttribute('role')).toBe('separator');
+            expect(listElement.hasAttribute('tabindex')).toBe(false);
             expect(header.element.getAttribute('aria-hidden')).toBe('true');
             expect(header.element.hasAttribute('tabindex')).toBe(false);
             expect(items.map(i => i.element.getAttribute('role'))).toEqual(['option', 'option', 'option']);
-            expect(items.map(i => i.element.getAttribute('tabindex'))).toEqual(['0', '0', '0']);
+            expect(tabIndexes()).toEqual(['-1', '0', '-1']);
             expect(items.map(i => i.element.getAttribute('aria-selected'))).toEqual(['false', 'true', 'false']);
 
             fixture.componentInstance.selectedId = 3;
             fixture.detectChanges();
             expect(items.map(i => i.element.getAttribute('aria-selected'))).toEqual(['false', 'false', 'true']);
+            expect(tabIndexes()).toEqual(['-1', '-1', '0']);
         });
 
-        it('should go back to the list roles when the items that bind selected are removed', () => {
-            fixture.componentInstance.items = [];
+        it('should put the tab stop on the first option when none is selected', () => {
+            fixture.componentInstance.selectedId = null;
             fixture.detectChanges();
+            expect(tabIndexes()).toEqual(['0', '-1', '-1']);
+        });
 
-            const listElement = list.element.nativeElement as HTMLElement;
-            expect(listElement.getAttribute('role')).toBe('list');
-            expect(listElement.hasAttribute('tabindex')).toBe(false);
-            expect(list.children.first.element.hasAttribute('aria-hidden')).toBe(false);
+        it('should keep the tab stop on the option focused last', () => {
+            list.items[2].element.focus();
+            fixture.detectChanges();
+            expect(tabIndexes()).toEqual(['-1', '-1', '0']);
         });
 
-        it('should keep the roles set by the app and not follow the listbox pattern with a role other than listbox', () => {
-            list.role = 'menu';
-            list.items[0].role = 'menuitem';
+        it('should move the tab stop when the active option is hidden or removed', () => {
+            list.items[1].hidden = true;
             fixture.detectChanges();
+            expect(tabIndexes()).toEqual(['0', '-1', '-1']);
 
-            const listElement = list.element.nativeElement as HTMLElement;
-            expect(listElement.getAttribute('role')).toBe('menu');
-            expect(listElement.hasAttribute('tabindex')).toBe(false);
-            expect(list.items[0].element.getAttribute('role')).toBe('menuitem');
-            expect(list.items[1].element.getAttribute('role')).toBe('listitem');
-            list.items.forEach(item => expect(item.element.hasAttribute('aria-selected')).toBe(false));
-            expect(pressKey(list.items[1].element, 'ArrowDown').defaultPrevented).toBe(false);
+            fixture.componentInstance.items = fixture.componentInstance.items.slice(2);
+            fixture.detectChanges();
+            expect(tabIndexes()).toEqual(['0']);
+        });
 
-            list.role = null;
+        it('should reset the items when the list stops being a listbox', () => {
+            list.role = 'list';
             fixture.detectChanges();
-            expect(listElement.hasAttribute('role')).toBe(false);
+
+            expect(list.children.first.element.hasAttribute('aria-hidden')).toBe(false);
+            list.items.forEach(item => {
+                expect(item.element.getAttribute('role')).toBe('listitem');
+                expect(item.element.hasAttribute('tabindex')).toBe(false);
+                expect(item.element.hasAttribute('aria-selected')).toBe(false);
+                expect(item.element.hasAttribute('aria-describedby')).toBe(false);
+            });
         });
 
-        it('should describe every option with the header of its group, unless it has its own description', () => {
+        it('should describe every option by the header of its group, unless it has its own description', () => {
             const groupedFixture = TestBed.createComponent(GroupedSelectableListComponent);
             groupedFixture.detectChanges();
-            const [ungrouped, item1, item2, item3] = groupedFixture.componentInstance.list.items;
+            const groupedList = groupedFixture.componentInstance.list;
+            const [employees, contractors] = groupedList.headers;
+            const [ungrouped, item1, item2, item3] = groupedList.items;
+
+            expect(employees.element.id).toBeTruthy();
+            expect(ungrouped.element.hasAttribute('aria-describedby')).toBe(false);
+            expect(item1.element.getAttribute('aria-describedby')).toBe(employees.element.id);
+            expect(item2.element.getAttribute('aria-describedby')).toBe('part-time');
+            expect(item3.element.getAttribute('aria-describedby')).toBe(contractors.element.id);
+        });
 
-            expect(ungrouped.element.hasAttribute('aria-description')).toBe(false);
-            expect(item1.element.getAttribute('aria-description')).toBe('Employees');
-            expect(item2.element.getAttribute('aria-description')).toBe('Part-time');
-            expect(item3.element.getAttribute('aria-description')).toBe('Contractors');
+        it('should only own options and hidden headers', () => {
+            const owned = Array.from((list.element.nativeElement as HTMLElement).children)
+                .filter(child => child.getAttribute('aria-hidden') !== 'true');
+            expect(owned.map(child => child.getAttribute('role'))).toEqual(['option', 'option', 'option']);
         });
 
         describe('Keyboard navigation', () => {
@@ -909,8 +919,7 @@ describe('List', () => {
                 expect(document.activeElement).toBe(items[0].element);
             });
 
-            it('should move the focus to the first and last item with Home and End, also from the list', () => {
-                const listElement = list.element.nativeElement as HTMLElement;
+            it('should move the focus to the first and last option with Home and End', () => {
                 const items = list.items;
                 items[1].element.focus();
 
@@ -919,17 +928,9 @@ describe('List', () => {
 
                 pressKey(items[2].element, 'Home');
                 expect(document.activeElement).toBe(items[0].element);
-
-                listElement.focus();
-                pressKey(listElement, 'ArrowDown');
-                expect(document.activeElement).toBe(items[0].element);
-
-                listElement.focus();
-                pressKey(listElement, 'ArrowUp');
-                expect(document.activeElement).toBe(items[2].element);
             });
 
-            it('should skip hidden items', () => {
+            it('should skip hidden options', () => {
                 const items = list.items;
                 items[1].hidden = true;
                 fixture.detectChanges();
@@ -939,7 +940,7 @@ describe('List', () => {
                 expect(document.activeElement).toBe(items[2].element);
             });
 
-            it('should activate the focused item with Enter and Space like a click', () => {
+            it('should click the focused option with Enter and Space, once per key press', () => {
                 const items = list.items;
                 const clickedItems: IgxListItemComponent[] = [];
                 list.itemClicked.subscribe((args: IListItemClickEventArgs) => clickedItems.push(args.item));
@@ -947,18 +948,17 @@ describe('List', () => {
 
                 expect(pressKey(items[1].element, 'Enter').defaultPrevented).toBe(true);
                 expect(pressKey(items[1].element, ' ').defaultPrevented).toBe(true);
+                expect(pressKey(items[1].element, ' ', true).defaultPrevented).toBe(true);
                 expect(clickedItems).toEqual([items[1], items[1]]);
             });
 
-            it('should not handle keys pressed in the content of an item, or Enter and Space on the list', () => {
+            it('should not handle keys pressed in the content of an option', () => {
                 const clickSpy = vi.fn();
                 list.itemClicked.subscribe(clickSpy);
-                const listElement = list.element.nativeElement as HTMLElement;
                 const title = list.items[0].element.querySelector('[igxListLineTitle]') as HTMLElement;
 
                 expect(pressKey(title, 'ArrowDown').defaultPrevented).toBe(false);
                 expect(pressKey(title, 'Enter').defaultPrevented).toBe(false);
-                expect(pressKey(listElement, ' ').defaultPrevented).toBe(false);
                 expect(clickSpy).not.toHaveBeenCalled();
             });
         });
diff --git a/projects/igniteui-angular/test-utils/list-components.spec.ts b/projects/igniteui-angular/test-utils/list-components.spec.ts
index 6033a6bbee..64e5be2255 100644
--- a/projects/igniteui-angular/test-utils/list-components.spec.ts
+++ b/projects/igniteui-angular/test-utils/list-components.spec.ts
@@ -87,7 +87,7 @@ export class ListWithSelectedItemComponent extends BasicListComponent {
 @Component({
     template: `
     <div #wrapper>
-        <igx-list>
+        <igx-list role="listbox" aria-label="Items">
             <igx-list-item [isHeader]="true">Header</igx-list-item>
             @for (item of items; track item.id) {
                 <igx-list-item [selected]="item.id === selectedId">
@@ -111,11 +111,11 @@ export class SelectableListComponent extends BasicListComponent {
 @Component({
     template: `
     <div #wrapper>
-        <igx-list aria-multiselectable="true">
+        <igx-list role="listbox" aria-label="Staff" aria-multiselectable="true">
             <igx-list-item [selected]="false">Ungrouped</igx-list-item>
             <igx-list-item [isHeader]="true">Employees</igx-list-item>
             <igx-list-item [selected]="true">Item 1</igx-list-item>
-            <igx-list-item [selected]="false" aria-description="Part-time">Item 2</igx-list-item>
+            <igx-list-item [selected]="false" aria-describedby="part-time">Item 2</igx-list-item>
             <igx-list-item [isHeader]="true">Contractors</igx-list-item>
             <igx-list-item [selected]="false">Item 3</igx-list-item>
         </igx-list>
@@ -129,7 +129,7 @@ export class GroupedSelectableListComponent extends BasicListComponent {
 @Component({
     template: `
     <div #wrapper>
-        <igx-list role="listbox" tabindex="0">
+        <igx-list tabindex="0">
             <igx-list-item [isHeader]="true" aria-hidden="true">Header</igx-list-item>
             <igx-list-item role="option" tabindex="-1" aria-selected="true">Item 1</igx-list-item>
         </igx-list>

@sdimchevski

Copy link
Copy Markdown

@adrianptrv @simeonoff

For the list itself I’d skip a separate focus style. With the roving tabindex Simeon suggested the list stops being a tab stop and Tab goes straight to an option so the problem goes away. 🙂

For the focused item let’s just copy the tree: an inset ring on :focus-visible. Same values as tree node per theme:

Material: 1px, secondary 500
Fluent: 1px, gray 800
Bootstrap: 1px, primary 200
Indigo: 2px, primary 400

It has to show on selected items too, since focus currently looks the same as hover and focused+selected looks the same as selected. We can drop the outline: none once that’s in. A dedicated token for the ring color in the list schema would be a nice bonus.

@adrianptrv

Copy link
Copy Markdown
Contributor Author

Changes made with the latest commit:

  • Opt-in: the listbox mode now turns on with role="listbox". [selected] alone changes nothing. The CHANGELOG notes that existing role="listbox" lists now get this behavior, the entry is under New Features.
  • Tab order: roving tabindex, like igx-tree. One tab stop on the option focused last, else the first selected one, else the first one.
  • Group headers: aria-hidden with a generated id. Options use aria-describedby, and an app's own aria-describedby, set or bound, is kept.
  • Smaller points:
    • Enter/Space ignore key repeat;
    • the arrow keys use items;
    • aria-busy while loading, and the loading message is hidden inside the listbox;
    • the README notes the synthetic MouseEvent;
    • the demo has no focusable buttons;
    • the skill reference mentions the listbox mode.
  • Focus ring: an inset ring on the focused option, also when it is selected, with the tree's values per theme, through the new item-focus-outline-color token released in igniteui-theming 30.3.0.

Also: a listbox with aria-activedescendant is left alone. The grid's Excel-style filter already uses role="listbox" with aria-activedescendant, and that focus model can't be combined with the roving tabindex: its options became an extra tab stop and Space toggled the wrong value.

@simeonoff
simeonoff self-requested a review November 23, 2026 12:07

@simeonoff simeonoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrianptrv thanks, this is much closer. The opt-in, the roving tabindex and the header ids all work the way we discussed. A few things left:

The library still allows igniteui-theming 30.2. The root package.json moves to ^30.3.0, but projects/igniteui-angular/package.json:78 still declares ^30.2.0. That's the range apps install with, and _base.scss:185 now uses item-focus-outline-color, which only exists in 30.3.0. An app that resolves 30.2.x will fail to compile the list styles. Please bump it there too.

Empty and loading messages in a listbox. Only the default loading template gets aria-hidden (list.component.html:10). The empty message, a custom dataLoadingTemplate, and the loading message when there are no items yet still render inside role="listbox" as children that aren't options. And since there are no options, there's no tab stop either, so a keyboard user tabs right past the list without learning it's empty or loading. That matters for filtered lists ("no results") and lists that load their data later.

Could we do what React Aria does here? While there are no options, the list itself is the tab stop, and whatever template is rendered (empty, loading, custom) is wrapped in an element with role="option". React Aria wraps its empty state in <div role="option" style="display: contents"> and makes the listbox tabbable when nothing inside it is focused. A keyboard user then lands on the list and hears its label and the message, and axe is happy: text that isn't an option inside a listbox is a critical aria-required-children failure, while an option isn't. aria-busy already covers the loading state. @sdimchevski that brings back the focus style for the list itself, but only for this case.

Header ids aren't cleaned up. When the list stops being a listbox, the ids generated for the headers (list-item.component.ts:331) stay. The item can remember the id it generated and remove it when the list isn't a listbox anymore, the same way it already does for aria-describedby. Can you add that to the role-switch spec?

Keys pressed inside a shadow root. The "keys pressed in the content of an option" spec only uses light DOM content. Options can contain web components (an igc-checkbox or igc-input), and keys pressed in those come from inside a shadow root. Can you add a case that hosts an input in an open shadow root inside an option and dispatches from it with composed: true? Without composed, the event stops at the shadow root and never reaches the list, so the spec would pass even if the list handled the key. Dispatching an ArrowDown from the option in the same spec shows the list does receive events. The preventImplicitSubmission() specs in core/src/core/utils.spec.ts have the setup.

A smaller one: item.list === this is repeated at list.component.ts:521, :585 and :605, and updateAttributes walks sortedChildren while the keyboard and focus handlers use items. An ownItems getter, sorted by index, that all three use would keep it in one place and the order the same everywhere.

@adrianptrv

Copy link
Copy Markdown
Contributor Author

The requests from the last comment were addressed with the last commit.
I set the focus ring styles on the list to match those used on the items.

simeonoff
simeonoff previously approved these changes Nov 24, 2026

@simeonoff simeonoff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrianptrv thanks, this addresses everything from the last round. The empty and loading states work the way we discussed, focus moves to the first option when items arrive while the list is focused, and the shadow root spec now proves the list actually receives the events.

@sdimchevski the list itself is a tab stop again, but only while it has no options (empty or loading). It reuses the item focus ring, item-focus-outline-color at 1px, 2px in Indigo. Can you confirm that's fine for the list?

Not blocking, for a follow-up: when the focused option is removed (e.g. the app deletes it on a key press), the focus drops to the body. Now that the list can be its own tab stop, it could move the focus to the next option, or to the list when none are left.

@sdimchevski

Copy link
Copy Markdown

@simeonoff @adrianptrv

Yes, reusing the item ring on the list is fine. Same cue for "you're here", no need for a separate style. Nice that it's an outline so it also shows up in forced colors mode.

Bootstrap's ring color is a bit low on contrast (same in the tree). I'll handle it in a separate PR for both, so it's not blocking here.

+1 on the follow-up for focus going to body when the focused option is removed.

@adrianptrv

Copy link
Copy Markdown
Contributor Author

Updates based on the comments from yesterday's meeting:

  • New selectable input – the listbox behavior (role="listbox", roving focus, keyboard navigation, aria-selected) is now opt-in through selectable. Lists without it, are unchanged. The role input is deprecated in favor of selectable.
  • Buttons inside items – I checked how buttons behave inside list items. They can be reached with a Tab.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

keyboard-navigation a11y keyboard navigation related items list ♿ a11y When the issue or PR is related to accessibility ❌ status: awaiting-test PRs awaiting manual verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[List]: igx-list-item is not keyboard accessible and selected state is not exposed to assistive technology

5 participants