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

onClick is not being passed to all elements of the switch #125

Open
Cenwulf opened this issue Nov 23, 2023 · 2 comments · May be fixed by #126
Open

onClick is not being passed to all elements of the switch #125

Cenwulf opened this issue Nov 23, 2023 · 2 comments · May be fixed by #126

Comments

@Cenwulf
Copy link

Cenwulf commented Nov 23, 2023

A switch component with onClick={(e) => e.stopPropagation()} attribute:

<Switch
  className="react-switch"
  onChange={this.handleChange}
  checked={this.state.checked}
  onClick={(e) => e.stopPropagation()}
/>

Nested in an accordion like component produces the following behaviour:
4d3525e33d

The onClick only appears to be passed to the background element of the component, clicking the circle element of the switch causes the click event to still be propagated to the switch's parent element even though stopPropagation() should be getting called for the entire switch component.

@esha111998 esha111998 linked a pull request Dec 12, 2023 that will close this issue
@cerahmed
Copy link

cerahmed commented Apr 4, 2024

Any workaround for this without modifying the source code?

@shauntrennery
Copy link

Any workaround for this without modifying the source code?

My work-around:

<div onClick={(e) => e.stopPropagation()}> <ReactSwitch checked={checked} disabled={disabled} onChange={handleChange}...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants