Course contentsShow
← Web Development
Lesson 1085 of 2,98219. Keyboard Navigation and FocusFree lesson

Composite Widget Focus Management

Coordinating focus between parent widgets and their active descendants.

Composite Widget Focus Management

You'll learn how to coordinate keyboard focus between a complex widget and the specific item currently active inside it.

What Are Composite Widgets?

A composite widget is a multi-part interactive component where only one descendant should be keyboard-accessible at a time, even though many parts exist. Think of a toolbar with multiple buttons, a listbox with many options, or a tree view with nested folders. These are "composite" because they're made of many interactive pieces working as one unit.

The Core Coordination Problem

When a user tabs to your composite widget, where should focus land? And when they navigate inside the widget with arrow keys (using patterns you've learned), how does the browser know which item is "active"?

The solution: the parent container receives actual DOM focus (tabindex="0"), while aria-activedescendant points to the ID of the currently active child. This means:

  • The container listens for keyboard events
  • The container tracks which child is logically "active"
  • Only the container appears in tab order
  • Screen readers announce the active child as if it had focus

Why This Matters

Without this coordination, users would need to tab through every button in a 20-button toolbar individually—exhausting! Instead, they tab once to enter the toolbar, then use arrow keys to move between buttons. The composite widget manages this behind the scenes.

Key Takeaway: Composite widget focus management uses aria-activedescendant on the parent and tabindex="-1" on children, letting the parent coordinate keyboard navigation while announcing the correct active item to assistive technologies.