Semantic-UI-React icon indicating copy to clipboard operation
Semantic-UI-React copied to clipboard

Radio: onChange not triggered for radio toggle with id

Open metr1ckzu opened this issue 6 years ago • 4 comments

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

metr1ckzu avatar Aug 06 '19 07:08 metr1ckzu

👋 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.

welcome[bot] avatar Aug 06 '19 07:08 welcome[bot]

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

MiceXx avatar Aug 12 '19 03:08 MiceXx

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.

carkod avatar Sep 27 '22 16:09 carkod

has any fix made for this?

bhavyagosai avatar Aug 12 '24 16:08 bhavyagosai