fix(docs): make the TreeView Custom onAction example selectable and non-disruptive - #2520
Open
mateoviilla1 wants to merge 1 commit into
Open
fix(docs): make the TreeView Custom onAction example selectable and non-disruptive#2520mateoviilla1 wants to merge 1 commit into
mateoviilla1 wants to merge 1 commit into
Conversation
…on-disruptive The example rendered checkboxes but ran in `selectionMode="single"`, so selecting a second item silently cleared the first — it read as "no further checkboxes can be selected". Checkboxes imply independent selection, so the example now uses `selectionMode="multiple"` to match its own affordance. Activating an item also fired a `window.alert`. A modal dialog on a checkbox toggle is an unannounced context change, which is disorienting for keyboard and screen reader users. The handler now writes to a `role="status"` region instead, so the action is announced without stealing focus.
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the TreeView documentation’s Custom onAction example to align behavior with its checkbox UI and to avoid disruptive modal dialogs during interaction, addressing the a11y issues reported in #2519 without changing the TreeView component itself.
Changes:
- Import
useStatein the MDX module so the live example can track action state. - Update the “Custom onAction” example to use
selectionMode="multiple"so multiple checkboxes can be selected. - Replace
window.alertwith arole="status"region that announces the last activated item without stealing focus.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Summary
Fixes the Custom onAction TreeView example, which had two problems reported
in an accessibility pass (#2519). Both were in the example itself — no component
change.
The two issues
Additional checkboxes could not be selected. The example rendered checkboxes
but ran in
selectionMode="single", so selecting a second item silently clearedthe first. With a checkbox affordance that reads as "nothing happened". It now
uses
selectionMode="multiple", which matches what the checkboxes imply.Activating an item opened an unannounced dialog. The handler called
window.alert. A modal dialog on a checkbox toggle is an unannounced contextchange, which is disorienting for keyboard and screen reader users. The handler
now writes into a
role="status"region, so the action is announced withoutstealing focus.
alert()is used in other docs examples (e.g. ActionMenu), and that is finethere — the affordance is a menu item, where activating is expected to do
something. On a checkbox it is not.
Notes
import { useState } from 'react'at the top of the mdx; hooks are notautomatically in scope in docs examples (same pattern as
Accordion.mdx).develop— the example came in with feat(TreeView): cascading selection (cascadeSelect / cascadeDeselect) and disabled nodes #2427. This isindependent of the TreeView virtualization work in feat(TreeView): add opt-in virtualization via height prop #2475, which does not touch
this example.
Testing
NODE_ENV=production webpack --bail) passes.updates without a dialog.
QA notes: on TreeView → Custom onAction, confirm several checkboxes can be
checked at once and that activating an item updates the status line instead of
opening a pop-up.
Ref #2519