Skip to content

fix(web): make expandable section headers keyboard operable - #42264

Closed
Ayaan Gazali (ayaangazali) wants to merge 1 commit into
microsoft:mainfrom
ayaangazali:fix-42263
Closed

fix(web): make expandable section headers keyboard operable#42264
Ayaan Gazali (ayaangazali) wants to merge 1 commit into
microsoft:mainfrom
ayaangazali:fix-42263

Conversation

@ayaangazali

Copy link
Copy Markdown

Rationale

Expandable's title carries role="button", aria-expanded and aria-controls, but it is a div with no tabIndex (packages/web/src/components/expandable.tsx:40-49). It tells assistive tech there is a button and then never takes focus, so in the trace viewer no attachment header and no section of network details can be expanded without a mouse. On main, focusing the real Request Headers header fails with toBeFocused receiving inactive.

The fix is the one already used for tab strips in #41434 and html-reporter chips in #42149: a native <button> plus a :focus-visible ring, no key handlers, Enter and Space come from the platform.

The plain div-to-button swap does not work here on its own. Both call sites render interactive content inside the title, the attachments tab a download link and network details the pretty-print toggle. A link or button nested inside a button is invalid and hides those controls from the accessibility tree, so they move to a titleChildren slot rendered next to the toggle rather than inside it.

The chevron-only variant (expandOnTitleClick unset, used by the UI mode filter panel) is left alone. Its title is an <input> and an icon-only toggle would need a label invented for it, which felt like a separate decision rather than something to fold in here.

Layout is unchanged. I measured the bounding boxes of the section header, the pretty-print button, the attachment name and the download link before and after, each against its own rebuilt bundle, and they are identical.

Test

expandable.spec.ts gets the keyboard case, plus a check that titleChildren stays outside the toggle. On current main the first one fails with toBeFocused receiving inactive, and the second fails because the link ends up nested in the button.

Fixes#42263


apologies if anything here is off, I worked through the fix with my own reasoning and used claude code as a sounding board for the design calls, especially the nested-interactive-content part. if I have got something wrong I would genuinely like to hear it. freshman in college trying to contribute something useful :)

The title rendered with expandOnTitleClick carries role="button",
aria-expanded and aria-controls, but it is a div with no tabIndex, so it
never takes focus. In the trace viewer that means no attachment and no
section of network details can be expanded without a mouse.
Render it as a native button, the same way tabs and chips were converted in
microsoft#41434 and microsoft#42149. Consumers put links and buttons in the title, which
cannot be nested inside a button, so those move to a titleChildren slot
rendered next to the toggle.
CopilotAI lite review requested due to automatic review settings August 15, 2026 23:48

CopilotAI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Trace viewer section headers announce as buttons but cannot be focused or expanded with the keyboard

3 participants

@ayaangazali@yury-s