Announce resource tree selection state to screen readers (#4798482)#2541
Open
jawelton74 wants to merge 4 commits into
Open
Announce resource tree selection state to screen readers (#4798482)#2541jawelton74 wants to merge 4 commits into
jawelton74 wants to merge 4 commits into
Conversation
The Data Explorer left-nav resource tree did not expose selection state to assistive technology. Screen readers announced tree items (e.g. "Documents, 1 of 2, level 3") without conveying whether the item was selected, failing MAS 4.1.2 (Name, Role, Value). Selection in the tree is a custom app-state concept (node.isSelected / shouldShowAsSelected) and does not use Fluent v9's built-in selectionMode. Wire the existing selection state to the aria-selected prop on TreeItem so selectable nodes announce "selected"/"not selected". Pure grouping nodes (no isSelected) omit the attribute, matching the ARIA single-select tree pattern. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 956998dd-4849-4f7d-a027-b7190018e089
Playwright tests ✅ passed
📁 Report: |
…o users/jawelton/a11yfix-4798482-072026
Playwright tests ✅ passed
📁 Report: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Preview this branch
Problem
In the Data Explorer left-navigation resource tree, screen readers (NVDA, JAWS, Narrator) announced tree items such as
"Documents, 1 of 2, level 3"but never conveyed whether the item was selected or not selected. Screen-reader users could not tell which node represented their current context.This failed MAS 4.1.2 – Name, Role, Value. The tree only reflected selection visually (via the
selectedItemstyle class) with no corresponding accessible state.Fix
Selection in the resource tree is a custom application-state concept (
node.isSelected()combined withshouldShowAsSelected, which highlights only the deepest selected node). It intentionally does not use Fluent UI v9's built-inTreeselectionMode, because that renders visible radio buttons / checkboxes.Fluent v9's
TreeItemexplicitly supports anaria-selectedprop. This change wires the existing selection state to that prop on eachTreeItem:Behavior, following the ARIA single-select tree pattern:
isSelected— databases, collections, Items/Documents, Settings/Scale, stored procedures, UDFs, triggers, conflicts, Home) announcearia-selected="true"when selected and"false"otherwise.isSelected— the Stored Procedures, User Defined Functions, Triggers, Schema folders and load more) omit the attribute entirely, so screen readers don't announce a misleading state for non-selectable containers.Because it reuses
shouldShowAsSelected, the announced state always mirrors the visual highlight (only the deepest selected node is"selected").Expected screen-reader result
"Documents, selected, 1 of 2, level 3"when the item is selected"Documents, not selected, 1 of 2, level 3"when it is not selectedChanges
src/Explorer/Controls/TreeComponent/TreeNodeComponent.tsx— addaria-selectedtoTreeItem.src/Explorer/Controls/TreeComponent/TreeNodeComponent.test.tsx— add unit tests for selected, unselected, non-selectable (grouping), and selected-parent-with-selected-descendant cases.src/Explorer/Controls/TreeComponent/__snapshots__/TreeNodeComponent.test.tsx.snap— updated snapshots.Testing
Unit tests:
npm run test:file -- src/Explorer/Controls/TreeComponent/TreeNodeComponent.test.tsx— 14 passed (4 new).Lint / TypeScript / Prettier:
eslint,tsc --noEmit, andprettier --checkall pass on the changed files.Manual E2E (dev server + a live SQL account): verified the rendered DOM and the platform accessibility tree.
aria-selectedtruewhen selected,falseotherwisecontainer1/Items(bug scenario)truewhen selected,falseotherwiseScale & Settingsfalsewhen not selectedSelecting a leaf moved
aria-selected="true"to that leaf and flipped its ancestor container back to"false", matching the visual highlight. Playwright's accessibility snapshot reportedtreeitem "Home" [selected], confirming the state reaches the platform accessibility API that NVDA consumes.Risk
Low. The change is additive and scoped to a single accessibility attribute; it does not alter selection logic, styling, or navigation behavior.