patternfly / patternfly/react-data-view
DataViewFilters: MenuToggle for filter category selector has no accessible name
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 4
- フォーク
- 21
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
packages/module/src/DataViewFilters/DataViewFilters.tsx から始め、46 行目と 80–88 行目付近の activeAttributeMenu state と MenuToggle を確認します。issue にある Name と Label のフィルターの子要素を指定して DataViewFilters をレンダリングし、その後 axe-core を実行します。初回レンダリング時にフィルターカテゴリセレクターに識別可能な accessible name があり、重大な button-name 違反がなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- react, typescript
- 領域
- accessibility, frontend
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 静か
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 78/100