ant-design icon indicating copy to clipboard operation
ant-design copied to clipboard

Table onRow -> onClick wrongly fired when clicking on the Checkbox (only when unselecting)

Open pepe95270 opened this issue 3 years ago • 6 comments

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  • Open the reproduction sandbox
  • Click on a checkbox to select a row
  • Click again on the same checkbox to unselect the row

What is expected?

The checkbox should be unselected

What is actually happening?

The checkbox is selected (the only way to unselect the row is to click on the row and not on the checkbox)

Environment Info
antd 5.0.1
React 18.3.0
System Windows 10
Browser Chrome

The bug is happening because the onRow -> onClick is triggered and the rowSelection -> onChange is also triggered.

pepe95270 avatar Nov 24 '22 01:11 pepe95270

I would like to work on this issue, please assign it to me

Pranshu1902 avatar Nov 26 '22 08:11 Pranshu1902

@Pranshu1902 Please feel free to PR on this : )

zombieJ avatar Nov 27 '22 15:11 zombieJ

It seems that the problem is resolved in 5.0.4 Related topic : https://github.com/ant-design/ant-design/pull/39078

pepe95270 avatar Dec 10 '22 16:12 pepe95270

In fact, this isn't resolved entirely. There is still a spot that will trigger the 2 events. To reproduce try clicking on the top limit of the checkbox, it won't work...

pepe95270 avatar Dec 10 '22 16:12 pepe95270

let me fix this problem.

edc-hui avatar Dec 13 '22 03:12 edc-hui

经过测试antd 5.x 和 antd 4.x 均有此问题

edc-hui avatar Dec 13 '22 06:12 edc-hui

antd@5.3.2 also has this problem.

I changed the rowSelectedKeys array using both the onSelectChange and onRowClick functions. when I click the checkbox border, the two functions fire at the same time.

reproduce link: https://stackblitz.com/edit/react-zqnkhw?file=demo.tsx

image

dbwcooper avatar Mar 28 '23 03:03 dbwcooper