Not able to prevent click event propagation on Checkbox/TableSelectRow
See original GitHub issueWhat package(s) are you using?
-
carbon-components
-
carbon-components-react
Detailed description
Describe in detail the issue you’re having.
Discover while we implement the ‘onRowClick’ on the table rows with TableSelectRow
. I don’t see a way to completely prevent the click from propagating from the Checkbox or the TableSelectRow because the event seems to be from the label
https://codesandbox.io/s/sparkling-sky-2d3uj?file=/src/index.js
Is this issue related to a specific component?
Checkbox TableSelectRow
What did you expect to happen? What happened instead? What would you like to see changed?
Checkbox.onClick
or TableSelectRow.onSelect
should prevent the click from bubbleing up.
What browser are you working in?
Chrome
What version of the Carbon Design System are you using?
Latest
What offering/product do you work on? Any pressing ship or release dates we should be aware of?
CP4D - WKC
Steps to reproduce the issue
- Step one
- Step two
- Step three
- etc.
Please create a reduced test case in CodeSandbox
https://codesandbox.io/s/sparkling-sky-2d3uj?file=/src/index.js
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (9 by maintainers)
Top GitHub Comments
@nelsonchen90 that codesandbox was super helpful, thanks! I see what you’re saying - the click event associated with the
input
can be caught throughonSelect
, but the click event associated with thelabel
can’t be caught throughonSelect
. This is because the event is placed directly on theinput
and not on a wrapper of theinput
andlabel
.I’m sure there’s some way we can address this. From my understanding, the
label
forInlineCheckbox
never renders visible text or a visible click target. I can’t think of a reason why a consumer would need access to the click event specifically from thelabel
. What might make the most sense here is to immediately callstopPropogation
on the labelclick
event internal toInlineCheckbox
.Sorry for the late response!
@tay1orjones the problem with InlineCheckbox and capture the click event is that there are 2 items being clicked in it
Although we can stop the click event from propagating by using
TableSelectRow.onSelect
there is still another event being ‘escaped’/propagated from thelabel
.I have created a super reduced case https://codesandbox.io/s/dark-fog-ubul2?file=/src/index.js