Skip to content

refactor(carousel): Tab order of carousel items - #17456

Open
rkaraivanov wants to merge 2 commits into
masterfrom
rkaraivanov/carousel-focus-tab-order
Open

refactor(carousel): Tab order of carousel items#17456
rkaraivanov wants to merge 2 commits into
masterfrom
rkaraivanov/carousel-focus-tab-order

Conversation

@rkaraivanov

Copy link
Copy Markdown
Member

Description

Changed the default tab order of the component,
focus now flows starting with its indicator container, navigation buttons, or the first focusable element in the active slide, whichever is available.

Motivation / Context

Related to #2291.

Type of Change (check all that apply):

  • Bug fix
  • New functionality
  • Behavioral change
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

Component(s) / Area(s) Affected:

How Has This Been Tested?

  • Unit tests
  • Manual testing
  • Automated e2e tests

Test Configuration:

  • Angular version:
  • Browser(s):
  • OS:

Screenshots / Recordings

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

Changed the default tab order of the component,
focus now flows starting with its indicator container, navigation buttons,
or the first focusable element in the active slide, whichever is available.

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.

Pull request overview

Updates the IgxCarouselComponent template to change the keyboard tab/focus order for improved accessibility and aligns the release notes to document the behavioral change.

Changes:

  • Reordered the carousel indicators before the navigation buttons in the DOM to make indicators appear earlier in the tab sequence.
  • Added a new changelog entry documenting the carousel’s updated default tab order.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
projects/igniteui-angular/carousel/src/carousel/carousel.component.html Moves the indicators block before navigation buttons to change the default tab sequence.
CHANGELOG.md Documents the carousel tab-order behavioral change (and includes minor formatting/whitespace adjustments nearby).

Comment on lines +19 to +21
@if (showIndicators) {
<div [ngClass]="indicatorsClass" [attr.role]="'tablist'" (keyup)="handleKeyUp($event)" (focusout)="handleFocusOut($event)" (click)="handleClick()" (keydown)="handleKeydown($event)">
@for (slide of slides; track slide) {

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.

Added three specs to carousel.component.spec.ts inside describe('Base Tests: ...') to lock in the expected tab order:

  1. should render indicators before navigation buttons in the DOM to preserve tab order — uses compareDocumentPosition to assert the indicators container precedes both the prev and next buttons in DOM order (indicators → prev → next).
  2. should have active indicator as first keyboard-focusable element when navigation is disabled — verifies the active indicator has tabindex="0", inactive ones have tabindex="-1", and the indicators container precedes the active slide when navigation buttons are absent.
  3. should have navigation buttons precede active slide when indicators are hidden — verifies nav buttons appear before the active slide in the DOM when indicators are hidden.

Comment thread CHANGELOG.md
Comment on lines +75 to +76
- `IgxCarouselComponent`
- Changed the default tab order of the component, focus now flows starting with its indicator container, navigation buttons, or the first focusable element in the active slide, whichever is available.
Copilot AI review requested due to automatic review settings July 27, 2026 15:14

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

projects/igniteui-angular/carousel/src/carousel/carousel.component.html:21

  • The PR changes focus/tab order by reordering focusable DOM (indicators now come before navigation buttons), but there is no accompanying unit test to prevent regressions. Since carousel.component.spec.ts already covers keyboard navigation and indicators focus, please add a spec that verifies the tab sequence/DOM order (e.g., active indicator/tab -> prev -> next -> first focusable in active slide when present), and the fallback behavior when indicators/navigation are disabled.
@if (showIndicators) {
    <div [ngClass]="indicatorsClass" [attr.role]="'tablist'" (keyup)="handleKeyUp($event)" (focusout)="handleFocusOut($event)" (click)="handleClick()" (keydown)="handleKeydown($event)">
        @for (slide of slides; track slide) {

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants