question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting disabled on iOS sometimes does not set disabled style

See original GitHub issue

Environment

System: OS: macOS 11.0.1 CPU: (12) x64 Intel® Core™ i7-9750H CPU @ 2.60GHz Memory: 89.49 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v14.15.0/bin/yarn npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.0 - /Users/luke/.gem/ruby/2.6.0/bin/pod SDKs: iOS SDK: Platforms: iOS 14.2, DriverKit 20.0, macOS 11.0, tvOS 14.2, watchOS 7.1 Android SDK: API Levels: 29, 30 Build Tools: 28.0.3, 29.0.2, 30.0.2 System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-30 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.6953283 Xcode: 12.2/12B45b - /usr/bin/xcodebuild Languages: Java: 1.8.0_275 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.3 => 0.63.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Description

If you set the disabled flag on the slider and run on iOS it will sometimes not set/unset the greyed out style. It appears to correctly set the style if you set disabled before first mount, however on an already mounted component setting the flag does not change the visual state (though it does stop it from being editable). Conversely if you have it disabled on mount and set it to disabled={false} after that it retains the disabled style until you change the value in the component.

Everything appears to work correctly in android.

Reproducible Demo

Initially disabled then re-enabled, doesn’t change visual state until value changes.

ezgif-3-32417a5496fe

Initially enabled, doesn’t change visual state when disabled.

ezgif-3-b1e8737e1ffc

Below is my code for the above demo app.

const App: () => React$Node = () => {
  const [a, setA] = useState(true);
  const [b, setB] = useState(false);
  return (
    <>
      <StatusBar barStyle="dark-content" />
      <SafeAreaView>
        <ScrollView
          contentInsetAdjustmentBehavior="automatic"
          style={styles.scrollView}>
          <Header />
          {global.HermesInternal == null ? null : (
            <View style={styles.engine}>
              <Text style={styles.footer}>Engine: Hermes</Text>
            </View>
          )}
          <View style={styles.body}>
            <Slider
              disabled={a}
              value={0.5}
              style={{
                height: 30,
              }}
            />
            <Button onPress={() => setA(!a)} title="Toggle slider" />
            <Slider
              disabled={b}
              value={0.5}
              style={{
                height: 30,
              }}
            />
            <Button onPress={() => setB(!b)} title="Toggle slider" />
          </View>
        </ScrollView>
      </SafeAreaView>
    </>
  );
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
BartoszKlonowskicommented, Mar 15, 2022

Thank you for checking and for letting us know @pinpong @Noitham! I will reopen this and will investigate.

1reaction
pinpongcommented, Jul 18, 2021

Hi, the example is not working on iOS. Seems the issue should open again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disabled input text color on iOS - iphone - Stack Overflow
You can use the readonly attribute instead of the disabled attribute, but then you will need to add a class because there isn't...
Read more >
<input type="reset"> - HTML: HyperText Markup Language
Disabling and enabling a reset button. To disable a reset button, specify the disabled global attribute on it, like so: < ...
Read more >
Enabling and disabling elements in forms - a free SwiftUI by ...
SwiftUI lets us disable any part of its forms or even the whole form, all by using the disabled() modifier. This takes a...
Read more >
Toggles - Selection and input - Human Interface Guidelines
Make sure the visual differences in a toggle's state are obvious. For example, you might add or remove a color fill, show or...
Read more >
Aria-disabled | Introduction to Accessibility - A11y-101
The disabled attribute often appears a little bit dimmed or transparent. Of course you can style this as well. Either way, sighted users...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found