[Android] Set AccessibilityNodeInfo.stateDescription so TalkBack stops reading "checked. on." on switches

Đang mở
#58,588 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
android, kotlin, react-native
Lĩnh vực
accessibility, mobile

Hướng nghiên cứu

Bắt đầu trong ReactAccessibilityDelegate.kt, tại phần xử lý STATE_CHECKED, và lần theo cách accessibilityRole và accessibilityState đi đến node Android. So sánh hành vi được đề xuất của ViewCompat hoặc AccessibilityNodeInfoCompat đối với stateDescription cho các role switch và checkbox, sau đó xác minh rằng thông báo không còn lặp lại trạng thái trong khi hành vi accessibility hiện có vẫn được giữ nguyên.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Needs: Author Feedback Needs: Repro
Description

On Android, a view with accessibilityRole="switch" and accessibilityState={{ checked: true }} is read by TalkBack as "checked. on.". TalkBack takes "on" from the Switch class name and "checked" from isChecked. It suppresses the generic word only when stateDescription is set (API 30+).

ReactAccessibilityDelegate.kt on main never calls setStateDescription: for STATE_CHECKED it sets only isCheckable and isChecked. No JS prop reaches stateDescription, so apps can't fix this without native code.

A related request, #34736 ("Custom State Descriptions"), was closed by the stale bot in 2023 without a PR.

Steps to reproduce
  1. Render <Pressable accessibilityRole="switch" accessibilityState={{ checked: true }} accessibilityLabel="Notifications" />.
  2. Turn on TalkBack and focus the element.
  3. Hear "checked. on." in the announcement.
Expected

The state is read once ("on"), not twice.

Suggested fix

In ReactAccessibilityDelegate, when accessibilityState.checked is set, also call ViewCompat.setStateDescription (or AccessibilityNodeInfoCompat.setStateDescription). For role switch it would be "on"/"off", and for role checkbox "checked"/"not checked", using Android's own localized strings. Alternatively, expose accessibilityValue.text as the stateDescription.

Versions
  • React Native 0.85.3 (Expo SDK 56). Also confirmed on main up to v0.88.0-rc.1 by reading the source.
  • TalkBack 17.
Ngôn ngữ chính
C++
Star
127k
Fork
25.3k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của react/react-native

Tất cả issue của react/react-native

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.