Replies: 2 comments 3 replies
-
This is know as event propagation can be prevented using stopPropagation(). Although to use this you'd have to create your own handleClick for Checkboxes if you're using the code shown in row-selection example.
All you have do is add |
Beta Was this translation helpful? Give feedback.
1 reply
-
Here is a complete version with handleClick, this way the checkbox click does not go to the row. function IndeterminateCheckbox({
indeterminate,
className = "",
onClick,
...rest
}: { indeterminate?: boolean } & HTMLProps<HTMLInputElement>) {
const ref = useRef<HTMLInputElement>(null);
useEffect(() => {
if (typeof indeterminate === "boolean" && ref.current) {
ref.current.indeterminate = !rest.checked && indeterminate;
}
}, [ref, indeterminate, rest.checked]);
const handleClick = (e: React.MouseEvent<HTMLInputElement>) => {
if (onClick) {
onClick(e);
}
e.stopPropagation();
};
return (
<input
type="checkbox"
ref={ref}
className={className + " cursor-pointer"}
onClick={handleClick}
{...rest}
/>
);
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have an issue with checkbox rows. Can we divide row
onClick
function and checkboxonClick
. Because on checkbox clicked it returns row onClick callback.Beta Was this translation helpful? Give feedback.
All reactions