-
Notifications
You must be signed in to change notification settings - Fork 101
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 is only draggable, not toggled by click #75
Comments
UP! I have the same problem. |
can you tell me how to make the circle part offcolor when i'm not clicking or focusing it ! |
Bump. I'm having the same issue |
@KidA001 I might not be correct with this, but could it be because every time you try to change the checked state, you call a Try to find a way to call |
Hi, sorry for the late response. @KidA001 Rendering the To everyone else in the thread: Could you fork this Code sandbox and create a minimal reproduction of the issue you're facing? EDIT: Here's a version that still works: https://codesandbox.io/s/jolly-ishizaka-k574z?file=/src/index.js |
Hey still facing the same issue
|
One way around this problem is to pass an empty callback function to the Switch and then wrap that Switch with a div element. Then pass onTap/onClick callback function to this div element. It will also allow you to drag and toggle if you don't drag the cursor out of the Switch UI model. (I did not find any way around this, frankly it doesn't bother me so I did not try to find any) |
This largely depends on how the checked state looks like in your app, what triggers its change, and lifecycle hooks you have that influence it... etc; the code you pasted unfortunately doesn't have this info. As a general rule of thumb, this appears to be an issue with the incorrect handling of the checked state, ie. it's either not changing on click, or it's immediately changing again or changing indefinitely in the background back and forth. What I do in cases like this to troubleshoot is I create a small line that's printing out the value of a state, something around the lines of |
@BSiddharth Could you provide a reproduction of the issue in code sandbox and explain the issue as well as what platform & browser are affected? |
@markusenglund Interestingly the simple code I wrote in the sandbox works. I will check my full code and will update it here later when I get time. Edit - Well it works now for some reason. I just uncommented the old code and commented the new one. And its working okay. Maybe because I updated to the latest Firefox 93.0 since last I ran that code?? |
I have the same problem on macOS now, with the recent Chrome version 96.0. It worked before. But now, I can enable a switch, but not disable it. And even worse: if you try to switch multiple switches on a page, all of the sudden all switches move. This does not happen on iOS or Firefox. On Android, it kinda works, but sometimes the animations are missing. |
Can anyone confirm derwaldgeist problem? |
Hi @markusenglund: Closing this. It seems as if this was a temporary hick-up of Chrome which vanished after I restarted my Mac. Sorry for the confusion. |
I'm on React
16.12.0
and react-switch5.0.1
When I render react-switch it is only draggable, but does not change/toggle when I click it. I found this issue however that seemed related to an iFrame which I'm not using.
I put a
console.log(checked)
in thehandleChange
function and it always outputsfalse
regardless of what the state of the switch is.Below is the component I'm loading the switch in. My only guess is it might have something to do with the
async
methods or with me setting the state in theView()
function, but it's not clear to me what I'm doing wrong.Any insight/help appreciated
The text was updated successfully, but these errors were encountered: