react / react/react-strict-dom

Button remains unclickable after disabled state changes

Open
#491 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
3.6k
Forks
206
PR merge metrics
No merged PRs in 30d

Description

Describe the issue

On Android if html.button state is set to disabled and then back to enabled the pressable itself remains unclickable, while it's children are clickable as expected. As with other similar issues in React Native a workaround is to set a key based on disabled state, but this issue doesn't seem to come from React Native, as it doesn't happen in React Native.

On iOS the button regains clickability as expected.

Expected behavior

Like on iOS, the pressable on Android should become clickable when the disabled state changes back to false.

Steps to reproduce

Platform: Android
OS version: 16.0 ("Baklava"); API 36.0
React version: 19.2.3
React Native version: 0.85.3
RSD version: 0.0.55

  1. Use the below example:
import { useState } from "react";
import { Button, Pressable, Text, View } from "react-native";
import { css, html } from "react-strict-dom";

export default function RootLayout() {
  const [buttonDisabled, setButtonDisabled] = useState(false);
  const [rnPresses, setRnPresses] = useState(0);
  const [rsdPresses, setRsdPresses] = useState(0);

  return (
    <View
      style={{ flex: 1, backgroundColor: "white", alignItems: "center", justifyContent: "center" }}
    >
      <Button
        title={"Toggle button disabled - now: " + buttonDisabled.toString()}
        onPress={() => {
          setButtonDisabled((prev) => !prev);
        }}
      />
      <View>
        <Text>RN Pressable - {rnPresses} presses</Text>
        <Pressable
          disabled={buttonDisabled}
          style={({ pressed }) => [
            { backgroundColor: "lightgreen", padding: 16 },
            pressed && { opacity: 0.5 },
          ]}
          onPress={() => {
            setRnPresses((prev) => prev + 1);
          }}
        >
          <Text style={{ backgroundColor: "black", color: "white", padding: 8 }}>Press me</Text>
        </Pressable>
      </View>
      <View>
        <Text>RSD Button - {rsdPresses} presses</Text>
        <html.button
          disabled={buttonDisabled}
          style={styles.button}
          onClick={() => {
            setRsdPresses((prev) => prev + 1);
          }}
        >
          <html.span style={styles.buttonText}>Press me</html.span>
        </html.button>
      </View>
    </View>
  );
}

const styles = css.create({
  button: {
    backgroundColor: "lightblue",
    opacity: {
      default: 1,
      ":active": 0.5,
    },
    padding: 16,
  },
  buttonText: {
    backgroundColor: "black",
    color: "white",
    padding: 8,
  },
});
  1. Run the app on Android device/emulator
  2. Verify that, for both RN and RSD cases, both pressable and it's children trigger press event (press count increases)
  3. Toggle button disabled state to true
  4. Toggle button disabled state to false
  5. Verify that for RN case both pressable and children regained clickability, while in RSD case only the label can be clicked to trigger an event
Test case

No response

Additional comments

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Android reproduction for html.button and compare its disabled-state handling with React Native Pressable. Trace the Android implementation and add a regression test for toggling disabled from true back to false; done means the button itself and its children respond to presses again.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript, react, react-native
Domain
frontend, mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.