react / react/react-native

Touchable focus events not triggering with keyboard (needed for accessibility)

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

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

API: Keyboard Issue: Author Provided Repro
Ngôn ngữ chính
C++
Star
127k
Fork
25.3k
Merge trung bình
1 ngày 23 giờ
Pull request đã merge (30 ngày)
4

Mô tả

Description

I am trying to add custom focus styles if a pressable is focused to make the keyboard focus visible in any case (dark/light mode, different background colors etc).

It seems like TouchableOpacity and TouchableHightlight both get forwarded from TouchableWithoutFeedback, which has the onFocus and onBlur events. I was trying to hold a focus state with these events to render styles dynamically. However, they do not get triggered at all, even if I use TouchableWithoutFeedback, which leads me to think that's the culprit.

Accessibility requires visibility of focus states. Is there another way to retrieve focus states?

Steps to reproduce

Here's a little example:

const [isFocused, setIsFocused] = useState(false);

return (
  // same with `TouchableWithoutFeedback` and `TouchableOpacity`
  <TouchableHighlight
    onFocus={() => setIsFocused(true)}
    onBlur={() => setIsFocused(false)}
    style={{
      backgroundColor: isFocused?"gray":"transparent",
    }}
  >
    ...
  </TouchableHighlight>
);
React Native Version

0.74.3

Affected Platforms

Runtime - Android

Output of npx react-native info
System:
  OS: macOS 14.5
  CPU: (12) arm64 Apple M2 Pro
  Memory: 109.05 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.13.1
    path: ~/Library/Caches/fnm_multishells/94190_1719818822541/bin/node
  Yarn: Not Found
  npm:
    version: 10.5.2
    path: ~/Library/Caches/fnm_multishells/94190_1719818822541/bin/npm
  Watchman:
    version: 2024.06.10.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/d.timur/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.2 AI-232.10300.40.2321.11668458
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /opt/homebrew/opt/openjdk@17/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/d.timur/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.2
    wanted: 0.74.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
Stacktrace or Logs
-
Reproducer

https://github.com/proohit/focus-example

Screenshots and Videos

No response

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.

Hướng nghiên cứu

Bắt đầu với reproducer focus-example được liên kết và theo dõi cách TouchableHighlight, TouchableOpacity và TouchableWithoutFeedback xử lý onFocus và onBlur trên Android. Xác nhận hành vi của keyboard-focus và xác định hoàn thành là khi các sự kiện focus được kích hoạt một cách đáng tin cậy để có thể render kiểu focus hiển thị tùy chỉnh.

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-native, typescript
Lĩnh vực
accessibility, mobile
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

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.