patternfly / patternfly/react-data-view
DataViewFilters: MenuToggle for filter category selector has no accessible name
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- TypeScript
- Star
- 4
- Fork
- 21
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu trong packages/module/src/DataViewFilters/DataViewFilters.tsx, xem xét state activeAttributeMenu và MenuToggle quanh các dòng 46 và 80–88. Render DataViewFilters với các filter children Name và Label từ issue, sau đó chạy axe-core. Hoàn tất khi bộ chọn danh mục bộ lọc có accessible name có thể nhận biết trong lần render ban đầu và violation button-name nghiêm trọng đã biến mất.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- react, typescript
- Lĩnh vực
- accessibility, frontend
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 78/100