react / react/react-native

Button `disabled` unexpected behavior on Android

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

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

Component: Button Platform: Android
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

On Android devices, the initial state of disabled for Button leads to unexpected behavior. When disabled is initially specified as true but later changes to false, the the background remains gray and disabled-like. This is unexpected behavior. This is not the case when disabled is initially specified as false.

Steps to reproduce
  1. Check out https://snack.expo.dev/@ctnelson1997/button-reset?platform=android
  2. Run on Android (Pixel 9 Pro used)
  3. When useState has an initial value of 0, the app works as expected.
  4. When useState has an initial value of 5, and the reset button is pressed, the button still appears disabled. This is unexpected behavior.
React Native Version

0.81.5

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info
System:
  OS: Windows 11 10.0.22631
  CPU: (14) x64 Intel(R) Core(TM) Ultra 5 125U
  Memory: 2.98 GB / 15.46 GB
Binaries:
  Node:
    version: 22.19.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn: Not Found
  npm:
    version: 10.9.3
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowAllTrustedApps: Disabled
IDEs:
  Android Studio: Not Found
  Visual Studio: Not Found
Languages:
  Java:
    version: 21.0.5
    path: C:\Program Files\Eclipse Adoptium\jdk-21.0.5.11-hotspot\bin\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.1.0
    wanted: 19.1.0
  react-native:
    installed: 0.81.5
    wanted: 0.81.5
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

info React Native v0.82.1 is now available (your project is running on v0.81.5).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.82.1
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.81.5&to=0.82.1
info For more info, check out "https://reactnative.dev/docs/upgrading?os=windows".
Stacktrace or Logs
N/A, issue is visual.
MANDATORY Reproducer

https://snack.expo.dev/@ctnelson1997/button-reset?platform=android

Screenshots and Videos
Image

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 bằng cách chạy trình tái hiện Snack bắt buộc trên Android với hai giá trị useState ban đầu được mô tả trong issue, sau đó lần theo phần triển khai React Native Button trên Android. Công việc được xem là hoàn tất khi việc đổi disabled từ true thành false sau reset cũng loại bỏ giao diện màu xám bị vô hiệu hóa, trong khi hành vi false thành false hiện có vẫn không thay đổi; hãy thêm kiểm thử hồi quy nếu xác định được điểm vào kiểm thử liên quan.

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

Đánh giá

Công nghệ
android, react-native
Lĩnh vực
mobile
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
55/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.