Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Checkbox: onClick doesn't fire when inside a Dropdown #2121
Comments
|
Looks like the Dropdown is overriding WorkaroundUse FixThe |
|
Note, children are not supported in a Dropdown. Use the |
|
I'll have a go at getting it fixed. |
|
@levithomason I don't think that DropdownItem is the issue. The Checkbox is displayed inside a DropdownHeader after all, not inside an Item. Adding |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions. |
|
don't close this issue |
|
@levithomason or anyone here, what's the update on this issue? any ideas on how to fix? |
|
I noticed that when you click on other Items or Headers, the order of called Dropdown methods are: But when you click on the checkbox its order is: So it appears that the |
|
Hi, I gave this issue a shot and implemented what was suggested by @levithomason in a previous comment. But this did not work as the onClick handler will never be called. I checked this by adding a debug() output into onClick. As it was also suggested to not use children, but instead use the options property, I changed the example to do so. But this also did not change anything. The onClick handler on the DropdownItem is simply not called. My guess is, that handleMouseDown() captures the event so it is not being further propagated. I could hook into handleMouseDown() and propagate onClick, but this kind of feels like a hack. Are there any other ideas? |
|
I tried to replicate the workaround @levithomason shared and it worked for me. |
|
I would like to trigger a simple onClick :
That would display the loading prop of the dropdown object onOpen, but it doesn't seem to work. Edit : onOpen is perfectly working, i was too dumb to check my shouldComponentUpdate. Sorry. |
|
Note, I've given a workaround and a proper fix here #2121 (comment). I've also included a reference to the proper pattern in another component that can be copied. Any PR implementing this would be much appreciated! |




Steps
Add a checkbox inside a dropdown, either as header or item.
Expected Result
onClickfiresActual Result
onClickdoesn't fireVersion
0.74.1
Testcase
https://codepen.io/anon/pen/zENBPx