Skip to content

Conversation

@mattcosta7
Copy link

@mattcosta7 mattcosta7 commented Oct 23, 2025

🎯 Changes

An a11y review we ran internally found some improvements could be made to our usage of the devtools panel.

Making a few tweaks to those items here to help close those on our end.

This pull request refactors the settings menus in Devtools.tsx to use accessible radio groups for mutually exclusive options, improving both accessibility and code maintainability. It also adds ARIA attributes to key interactive elements throughout the UI for better screen reader support, and updates styling to visually indicate selected options using the data-checked attribute.

Slightly clearer when viewed without whitespace diffs - https://github.com/TanStack/query/pull/9806/files?diff=split&w=1

I don't see any tests related to these currently, and haven't added here, but happy to try to do something like that with some guidance - although the changes here should not substantially change any behaviors as they're mostly semantic

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes
    • Improved accessibility with enhanced ARIA labels, input/label associations, and announced status regions for devtools panel updates.
    • Refined selection controls to use consistent, keyboard-accessible radio-style behavior for position, theme, and query visibility.
    • Better keyboard and screen reader interaction for explorer expanders and settings controls.

@changeset-bot
Copy link

changeset-bot bot commented Oct 23, 2025

🦋 Changeset detected

Latest commit: caa1baf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@tanstack/query-devtools Patch
@tanstack/angular-query-experimental Patch
@tanstack/react-query-devtools Patch
@tanstack/solid-query-devtools Patch
@tanstack/svelte-query-devtools Patch
@tanstack/vue-query-devtools Patch
@tanstack/angular-query-persist-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 23, 2025

Walkthrough

Refactors Query Devtools UI: replaces imperative DropdownMenu item selections with declarative RadioGroup/RadioItem controls for position, theme, and disabled-queries; adds ARIA attributes (aria-label, aria-live/role/atomic, aria-expanded) and links form labels/inputs with generated IDs for improved accessibility.

Changes

Cohort / File(s) Change Summary
Release metadata
\.changeset/slick-clubs-lay.md
Added new changeset file for a patch release documenting accessibility improvements.
Devtools UI refactor
packages/query-devtools/src/Devtools.tsx
Replaced multiple DropdownMenu.Item usages with DropdownMenu.RadioGroup / RadioItem (controlled value-based selection). Switched from per-item onSelect callbacks to onChange handlers updating localStore. Added ARIA attributes (e.g., aria-label, role="status", aria-live="polite", aria-atomic="true"). Adjusted selection styling to use [data-checked] selector.
Explorer accessibility
packages/query-devtools/src/Explorer.tsx
Added createUniqueId, generated inputId to link label and input, replaced span with proper label, and added aria-expanded to expander button.

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
participant User
participant DevtoolsUI as Devtools UI
participant RadioGroup
participant LocalStore

Note over DevtoolsUI,RadioGroup: New/changed flow (declarative radio)
User->>DevtoolsUI: open settings / click option
DevtoolsUI->>RadioGroup: set selected value (controlled)
RadioGroup->>LocalStore: onChange -> update preference
LocalStore-->>DevtoolsUI: new state (render reflect)

mermaid
sequenceDiagram
autonumber
participant User
participant DevtoolsUI as Devtools UI
participant DropdownItem as DropdownMenu.Item
participant LocalStore

Note over DevtoolsUI,DropdownItem: Previous flow (imperative onSelect)
User->>DevtoolsUI: open settings / click option
DevtoolsUI->>DropdownItem: item selected
DropdownItem->>LocalStore: onSelect callback -> update preference
LocalStore-->>DevtoolsUI: new state (render reflect)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 I hopped through menus, tidy and bright,

Swapped clicks for radios, gave labels their light.
aria-live whispers, ids linked with care,
Now devtools speak softly — accessible, aware. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed The pull request description is well-structured and follows the repository template completely. It includes a comprehensive "Changes" section explaining the refactoring work, ARIA attribute additions, and styling updates with clear motivation from an internal a11y review. Both checklist items in the "Checklist" section are properly marked as completed, indicating the contributing guide was followed and testing was performed locally. The "Release Impact" section correctly identifies that this affects published code and confirms a changeset was generated, leaving the docs/CI-only option unchecked appropriately.
Title Check ✅ Passed The PR title "Improve devtools accessibility by adding aria attributes, using semantic components and field labels" is directly aligned with the changes in the changeset. The raw summary confirms that the PR includes adding ARIA attributes (aria-label, aria-live, aria-expanded, role="status"), refactoring to use semantic components (RadioGroup/RadioItem instead of DropdownMenu.Item), and adding proper field labels with generated IDs. The title captures the primary objective of the changeset—improving accessibility—and specifically references the three main mechanisms being employed to achieve it, making it clear and specific without being overly verbose or generic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Oct 23, 2025

View your CI Pipeline Execution ↗ for commit caa1baf

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 4m 3s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 36s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-23 18:31:59 UTC

Comment on lines +1016 to +1017
aria-label="Open settings menu"
title="Open settings menu"
Copy link
Author

Choose a reason for hiding this comment

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

This menu item has no visible text, so adding label and title to account for this for screen readers

<span>Right</span>
<ArrowRight />
</DropdownMenu.Item>
<DropdownMenu.RadioGroup aria-label="Position settings" value={props.localStore.position} onChange={value => setDevtoolsPosition(value as DevtoolsPosition)}>
Copy link
Author

Choose a reason for hiding this comment

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

Replaced DropdownMenu.Item with DropdownMenu.Radio(Group|Item)

These internally handle checked states - so moved the selected styles into data-checked instead of a separate class

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 23, 2025

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9806

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@9806

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9806

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@9806

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@9806

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@9806

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9806

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@9806

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@9806

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@9806

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@9806

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@9806

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@9806

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@9806

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@9806

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@9806

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@9806

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@9806

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@9806

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@9806

commit: caa1baf

@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 0% with 36 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@6c272bd). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9806   +/-   ##
=======================================
  Coverage        ?   21.35%           
=======================================
  Files           ?       42           
  Lines           ?     2388           
  Branches        ?      600           
=======================================
  Hits            ?      510           
  Misses          ?     1641           
  Partials        ?      237           
Components Coverage Δ
@tanstack/angular-query-experimental 93.85% <ø> (?)
@tanstack/eslint-plugin-query ∅ <ø> (?)
@tanstack/query-async-storage-persister ∅ <ø> (?)
@tanstack/query-broadcast-client-experimental ∅ <ø> (?)
@tanstack/query-codemods ∅ <ø> (?)
@tanstack/query-core ∅ <ø> (?)
@tanstack/query-devtools 3.51% <0.00%> (?)
@tanstack/query-persist-client-core ∅ <ø> (?)
@tanstack/query-sync-storage-persister ∅ <ø> (?)
@tanstack/query-test-utils ∅ <ø> (?)
@tanstack/react-query ∅ <ø> (?)
@tanstack/react-query-devtools 10.00% <ø> (?)
@tanstack/react-query-next-experimental ∅ <ø> (?)
@tanstack/react-query-persist-client ∅ <ø> (?)
@tanstack/solid-query ∅ <ø> (?)
@tanstack/solid-query-devtools 61.90% <ø> (?)
@tanstack/solid-query-persist-client ∅ <ø> (?)
@tanstack/svelte-query ∅ <ø> (?)
@tanstack/svelte-query-devtools ∅ <ø> (?)
@tanstack/svelte-query-persist-client ∅ <ø> (?)
@tanstack/vue-query ∅ <ø> (?)
@tanstack/vue-query-devtools ∅ <ø> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mattcosta7 mattcosta7 marked this pull request as ready for review October 23, 2025 16:04
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/query-devtools/src/Devtools.tsx (1)

1217-1257: Consider letting data-checked handle selection indication.

The RadioGroup correctly implements controlled selection, but the manual CheckCircle icons (lines 1232-1238, 1249-1255) are redundant with the [data-checked] styling defined at lines 3519-3528. The data-checked attribute already provides visual indication of the selected state.

You could simplify by removing the manual icon logic and relying solely on the CSS styling:

 <DropdownMenu.RadioItem
   value="false"
   class={cx(
     styles().settingsSubButton,
     'tsqd-settings-menu-position-btn',
     'tsqd-settings-menu-position-btn-show',
   )}
 >
   <span>Show</span>
-  <Show when={props.localStore.hideDisabledQueries !== 'true'}>
-    <CheckCircle />
-  </Show>
 </DropdownMenu.RadioItem>
 <DropdownMenu.RadioItem
   value="true"
   class={cx(
     styles().settingsSubButton,
     'tsqd-settings-menu-position-btn',
     'tsqd-settings-menu-position-btn-hide',
   )}
 >
   <span>Hide</span>
-  <Show when={props.localStore.hideDisabledQueries === 'true'}>
-    <CheckCircle />
-  </Show>
 </DropdownMenu.RadioItem>

If you want to keep the icon for extra visual clarity, consider adding it via CSS using the data-checked selector to maintain consistency with the RadioGroup pattern.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6c272bd and 9f75531.

📒 Files selected for processing (3)
  • .changeset/slick-clubs-lay.md (1 hunks)
  • packages/query-devtools/src/Devtools.tsx (8 hunks)
  • packages/query-devtools/src/Explorer.tsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/query-devtools/src/Devtools.tsx (2)
packages/query-devtools/src/contexts/QueryDevtoolsContext.ts (1)
  • DevtoolsPosition (6-6)
packages/query-devtools/src/icons/index.tsx (8)
  • ArrowUp (63-81)
  • ArrowDown (83-101)
  • ArrowLeft (103-124)
  • ArrowRight (126-147)
  • Sun (149-167)
  • Moon (169-187)
  • Monitor (189-207)
  • CheckCircle (432-450)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test
🔇 Additional comments (7)
packages/query-devtools/src/Explorer.tsx (1)

335-335: LGTM! aria-expanded enhances screen reader support.

Adding aria-expanded to the expander button properly communicates the expanded/collapsed state to assistive technologies.

packages/query-devtools/src/Devtools.tsx (5)

1003-1003: LGTM! Good accessibility improvements.

Removing unnecessary template literals and adding aria-label to icon-only buttons improves code clarity and screen reader support.

Also applies to: 1016-1017


1066-1117: Excellent refactor to RadioGroup pattern.

Replacing imperative onSelect handlers with the declarative RadioGroup/RadioItem pattern is both more maintainable and semantically correct for mutually exclusive options. The controlled value-based selection with onChange and aria-label properly communicates the menu's purpose to assistive technologies.


1147-1187: LGTM! Consistent RadioGroup implementation.

The theme preference menu follows the same accessible pattern as the position settings, with appropriate aria-label and controlled selection.


1953-1955: Excellent use of ARIA live regions.

Adding role="status", aria-live="polite", and aria-atomic="true" to the details panels properly announces query/mutation state changes to screen readers without interrupting other announcements.

Also applies to: 2367-2369


3519-3528: LGTM! Appropriate styling for RadioItem selection.

The [data-checked] selector is the standard way RadioItem communicates selection state. The styling provides clear visual feedback for the selected option.

.changeset/slick-clubs-lay.md (1)

1-5: LGTM! Changeset properly documents the accessibility improvements.

The patch release type is appropriate for these non-breaking accessibility enhancements.

@mattcosta7 mattcosta7 changed the title Update some a11y bits in devtools Improve devtools accessibility by adding aria attributes, using semantic components and field labels Oct 23, 2025
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.

1 participant