Semantic-Org / Semantic-UI-React

The official Semantic-UI-React integration
https://react.semantic-ui.com
MIT License
13.23k stars 4.05k forks source link

Radio: onChange not triggered for radio toggle with id #3737

Open metr1ckzu opened 5 years ago

metr1ckzu commented 5 years ago

Bug Report

onChange not triggered on Radio with toggle and id props. And does okay without id or with name props.

Steps

  1. Add id and toggle props to Radio component
  2. Click on radio element

Expected Result

onChange should be triggered.

Actual Result

onChange is not triggered.

Version

0.87.3

Testcase

https://codesandbox.io/embed/semantic-ui-react-example-yowvx

welcome[bot] commented 5 years ago

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you've completed all the fields in the issue template so we can best help.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

MiceXx commented 5 years ago

Seems like it was intentional? https://github.com/Semantic-Org/Semantic-UI-React/blob/9bcc76a82cd02fd4e0cbc9afdef8904af04dcf91/test/specs/modules/Checkbox/Checkbox-test.js#L244

carkod commented 2 years ago

Would it not work for you with the onClick? It works with your example.

So I've investigated this a bit, and just like @MiceXx said, apparently in PR the id was disabled to avoid calling the onChange handler twice. But the side effect in turn has caused this to not fire when id is provided. So what I'm going to do instead of this, is to e.preventDefault() see if it can fix the issue without breaking the "onChange firing twice" fix.

bhavyagosai commented 3 months ago

has any fix made for this?