patternfly / patternfly/react-data-view
DataViewFilters: MenuToggle for filter category selector has no accessible name
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
Description
The DataViewFilters component renders a MenuToggle as the filter category selector (e.g., to switch between "Name" and "Label" filters). This button has no accessible name, causing a critical button-name axe violation (WCAG 4.1.2).
Root cause
activeAttributeMenuis initialized as''(line 46)- It's only populated via
useEffectafter the first render (lines 63–65) - The
MenuTogglehas noaria-labelprop (lines 80–88)
On the initial render, the button has no text content, no aria-label, no aria-labelledby, and no title — making it completely invisible to screen readers.
// Line 46 — empty initial state
const [activeAttributeMenu, setActiveAttributeMenu] = useState<string>('');
// Lines 80-88 — no aria-label, children is '' on first render
const attributeToggle = (
<MenuToggle
ref={attributeToggleRef}
onClick={() => setIsAttributeMenuOpen(!isAttributeMenuOpen)}
isExpanded={isAttributeMenuOpen}
icon={toggleIcon}
>
{activeAttributeMenu}
</MenuToggle>
);
Suggested fix
Two changes:
-
Initialize
activeAttributeMenufrom the first child'stitleprop synchronously instead of viauseEffect, so it's never empty:const initialTitle = useMemo(() => filterItems[0]?.title ?? '', []); const [activeAttributeMenu, setActiveAttributeMenu] = useState<string>(initialTitle); -
Add a fallback
aria-labelon theMenuToggle:<MenuToggle aria-label="Filter by" ... >
How to reproduce
Render DataViewFilters with 2+ filter children and run axe-core:
<DataViewFilters>
<DataViewTextFilter filterId="name" title="Name" />
<DataViewTextFilter filterId="label" title="Label" />
</DataViewFilters>
axe reports:
critical button-name: Buttons must have discernible text
Target: .pf-m-filter-group > div:nth-child(1) > .pf-v6-c-menu-toggle
Environment
-
@patternfly/react-data-view: 6.5.0 -
Detected by: axe-core 4.11 via
@axe-core/playwright
Related
- #21 (DataView accessibility meta-issue)
Jira Issue: PF-4416
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/module/src/DataViewFilters/DataViewFilters.tsx, reviewing the activeAttributeMenu state and the MenuToggle around lines 46 and 80–88. Render DataViewFilters with the Name and Label filter children from the issue, then run axe-core. Done means the filter category selector has a discernible accessible name on the initial render and the critical button-name violation is gone.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- accessibility, frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100