Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trackColor.false doesn't persist when Android Switch component is toggled #23962

Closed
shaundon opened this issue Mar 15, 2019 · 1 comment
Closed
Labels
Bug Component: Switch Platform: Android Android applications. Resolution: Fixed A PR that fixes this issue has been merged. Resolution: Locked This issue was locked by the bot. Resolution: PR Submitted A pull request with a fix has been provided.

Comments

@shaundon
Copy link

🐛 Bug Report

**Note: ** This is related to #23956. I expect the same thing is causing both issues.

The switch component has a trackColor prop with true and false props within, to change the colour of the track when the switch is enabled and disabled respectively.

When trackColor.false is set, it works initially but then reverts to the original grey colour when the switch is toggled on then off.

To Reproduce

  1. Use trackColor.false on a Switch component on Android.
  2. Toggle the switch on then off.
  3. The track colour reverts to grey from the colour you set.

Expected Behavior

The colour to not be reverted when the switch is toggled.

Code Example

<Switch 
    thumbColor="red" 
    trackColor={{
        true: "yellow",
        false: "purple",
    }} 
/>

Kapture 2019-03-15 at 19 15 58

Here's a test repo I made to showcase the issue: https://github.com/shaundon/switchdemo

Environment

  React Native Environment Info:
    System:
      OS: macOS 10.14.1
      CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
      Memory: 91.06 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
      Yarn: 1.13.0 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 21, 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 25.0.0, 26.0.1, 26.0.2, 27.0.3, 28.0.3
        System Images: android-21 | Google APIs Intel x86 Atom, android-24 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5314842
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.1 => 0.59.1
    npmGlobalPackages:
      create-react-native-app: 2.0.2
      react-native-cli: 2.0.1
@JKCooper2
Copy link

Not reproducible in older versions of RN (https://snack.expo.io/@jkcooper/rn23962-switch-track-color) so may be a newly introduced bug

dulmandakh added a commit to dulmandakh/react-native that referenced this issue Mar 16, 2019
@patrickkempff patrickkempff added Resolution: PR Submitted A pull request with a fix has been provided. Resolution: Fixed A PR that fixes this issue has been merged. labels Mar 16, 2019
grabbou pushed a commit that referenced this issue Mar 22, 2019
Summary:
fixes #23962, where trackColor is reset when value changed. This PR will set trackColor corresponding trackColor every-time value changes.

[Android] [Changed] - Fix Switch trackColor
Pull Request resolved: #23977

Differential Revision: D14495206

Pulled By: hramos

fbshipit-source-id: d712f540cd3f8359d6e85f79c12732689870a112
@facebook facebook locked as resolved and limited conversation to collaborators Mar 16, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Component: Switch Platform: Android Android applications. Resolution: Fixed A PR that fixes this issue has been merged. Resolution: Locked This issue was locked by the bot. Resolution: PR Submitted A pull request with a fix has been provided.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants