react / react/react-native

Button `disabled` unexpected behavior on Android

Offen
#54,293 6 Kommentare 7 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Component: Button Platform: Android
Vorherrschende Sprache
C++
Sterne
127k
Forks
25.3k
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
4

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit der Ausführung des obligatorischen Snack-Reproducers auf Android mit den beiden im Issue beschriebenen anfänglichen useState-Werten und verfolgen Sie anschließend die React Native Button Android-Implementierung. Als abgeschlossen gilt die Änderung, wenn das Ändern von disabled von true zu false nach reset auch die graue deaktivierte Darstellung entfernt, während das bestehende Verhalten von false zu false unverändert bleibt; fügen Sie eine Regressionstestabdeckung hinzu, wenn der relevante Test-Einstiegspunkt identifiziert wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, react-native
Bereich
mobile
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.