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

Switch animation does not seem to work correctly when updating value prop #31975

Open
mrAnomalyy opened this issue Aug 6, 2021 · 7 comments
Open
Labels
Component: Switch Never gets stale Prevent those issues and PRs from getting stale Platform: iOS iOS applications.

Comments

@mrAnomalyy
Copy link

Hi. I noticed a strange behaviour of switch component when value is changed any other way than actual interact with switch. (so, basically, when we set a new prop value)

Description

When you set new "value" prop value Android animation is working, but it does not have that ripple effect (idk if it is supposed to work like that), and iOS animation is not working at all that looks not pretty.

React Native version:

$ react-native info

System:
OS: macOS 11.5
CPU: (8) arm64 Apple M1
Memory: 68.00 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.2.0 - ~/.nvm/versions/node/v16.2.0/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v16.2.0/bin/yarn
npm: 7.16.0 - ~/.nvm/versions/node/v16.2.0/bin/npm
Watchman: 2021.06.07.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK:
API Levels: 28, 29, 30
Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 31.0.0, 31.0.0
System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-30 | Google APIs ARM 64 v8a, android-S | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_292 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: 0.64.1 => 0.64.1
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps To Reproduce

Just update a value prop for Switch component

Snack, code example, screenshot, or link to a repository:

See an example here: mrAnomalyy/rn-switch-issue

iOS GIF

Simulator Screen Recording - iPhone 12 - 2021-08-06 at 14 12 56

Android GIF

Screen-Recording-2021-08-06-at-2

P.S. I've been digging on RN iOS code for Switch component and I was able to fix the issue just by replacing this value (see pic below) with YES, but obviously it does not look like a good solution.

image

@safaiyeh
Copy link
Contributor

safaiyeh commented Aug 6, 2021

Interesting, took a look: the only time setOn is used is here:

[(UISwitch *)view setOn:value animated:NO];

We should have more configs, i.e. enableAnimationOnChange, etc.

@mrAnomalyy
Copy link
Author

Interesting, took a look: the only time setOn is used is here:

[(UISwitch *)view setOn:value animated:NO];

We should have more configs, i.e. enableAnimationOnChange, etc.

I don't really think we need configuration of this thing. It should be animated always. Why not?

@safaiyeh
Copy link
Contributor

safaiyeh commented Aug 6, 2021

I don't really think we need configuration of this thing. It should be animated always. Why not?

Well when it comes to building components for any dev to consume, having the option is better than not. This has been the behavior for a long time and not many issues have came up about it. So we should always provide any behaviors to the devs for them to utilize.

@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Mar 30, 2022
@mattmcdonald-uk
Copy link

This is still an issue.

@github-actions github-actions bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Mar 31, 2022
@lorenc-tomasz
Copy link

Still an issue

@cortinico cortinico added the Never gets stale Prevent those issues and PRs from getting stale label Oct 24, 2023
@Acetyld
Copy link

Acetyld commented Mar 13, 2024

Still open till this date ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Switch Never gets stale Prevent those issues and PRs from getting stale Platform: iOS iOS applications.
Projects
None yet
Development

No branches or pull requests

6 participants