frontend: ShowHideLabel: Fix aria attributes - #7267
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Alok-work23 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
unlikelyzero
left a comment
There was a problem hiding this comment.
Thanks for tracking down this aria fix — moving the IconButton out of the span it references is the right call, and it does correctly resolve the aria-controls/aria-expanded relationship.
A couple of things before merging though:
-
Moving the button out of the
<span>also changes its layout participation. When collapsed, the Box isdisplay: flex, so the span and the button are now two separate flex items instead of the button being inline content inside the span. On multi-line text (which is the common case for long messages in table cells — Overview.tsx, ObjectEventList.tsx, CustomResourceInstancesList.tsx all use this), the button can end up detached as a stretched column beside the wrapped text instead of trailing right after the ellipsis. Can you check this visually in Storybook at a narrow width with a long string? If it's an issue, adjusting the Box's flex properties (e.g.flexWrap+alignItems: flex-end) or keeping the button flowing inline would fix it while still keeping the DOM structure change for the aria fix. -
frontend/.axe-storybook-baseline.test-a11y.jsonstill lists bothcommon/ShowHideLabel/Basicandcommon/ShowHideLabel/Expandedunderaria-allowed-attr. Since that's an allowlist, CI isn't actually proving the violation is gone — if the fix were incomplete, or regressed later, it'd still pass silently. Can you run the axe check locally against these two stories and, if clean, remove those two baseline entries so CI enforces it going forward?
Separately (not blocking this PR, just flagging while I was in the code): needsButton in the useMemo unconditionally returns true when expanded is true, so if ShowHideLabel is ever initialized with show={true} on text shorter than maxChars, it renders a Collapse button that disappears the moment it's clicked. That logic predates this PR though, so probably worth its own follow-up rather than folding into this one.
Nice work on the core fix — just want the layout and CI-enforcement pieces closed out first.
|
Thanks @unlikelyzero for the detailed review! I'll address the two points before making further changes:
I'll leave the existing |
There was a problem hiding this comment.
Pull request overview
Moves the ShowHideLabel toggle outside the text span to correct ARIA semantics.
Changes:
- Separates the interactive button from the label text.
- Updates Basic and Expanded snapshots.
- CI was still running with no reported failures.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
ShowHideLabel.tsx |
Updates DOM structure and ARIA ownership. |
ShowHideLabel.Basic.stories.storyshot |
Updates collapsed-state snapshot. |
ShowHideLabel.Expanded.stories.storyshot |
Updates expanded-state snapshot. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
2c1bc4e to
fb5edb3
Compare
|
hii @illume , Thank You ! |
Summary
This PR fixes an accessibility issue in the ShowHideLabel component by moving the expand/collapse IconButton outside of the label element. The button now correctly controls the label text while keeping aria-expanded and aria-controls on the interactive element.
Related Issue
Fixes #7194
Changes
Steps to Test
Screenshots (if applicable)
N.A.
Notes for the Reviewer