Skip to content

Commit

Permalink
Revert "feat(checkbox): add onClick prop (#9827)"
Browse files Browse the repository at this point in the history
This reverts commit dd1d037.
  • Loading branch information
tay1orjones authored Dec 9, 2021
1 parent a69b00e commit 3bdf29b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 24 deletions.
4 changes: 0 additions & 4 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ Map {
"defaultProps": Object {
"indeterminate": false,
"onChange": [Function],
"onClick": [Function],
},
"propTypes": Object {
"checked": Object {
Expand Down Expand Up @@ -350,9 +349,6 @@ Map {
"onChange": Object {
"type": "func",
},
"onClick": Object {
"type": "func",
},
"title": Object {
"type": "string",
},
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/components/Checkbox/Checkbox-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ const props = () => ({
hideLabel: boolean('No label (hideLabel)', false),
wrapperClassName: text('Wrapper CSS class name (wrapperClassName)', ''),
onChange: action('onChange'),
onClick: action('onClick'),
});

export const playground = () => (
Expand Down
20 changes: 1 addition & 19 deletions packages/react/src/components/Checkbox/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const Checkbox = React.forwardRef(function Checkbox(
id,
labelText,
onChange,
onClick,
indeterminate,
hideLabel,
wrapperClassName,
Expand All @@ -45,15 +44,7 @@ const Checkbox = React.forwardRef(function Checkbox(
);

return (
/*
The a11y rules below are disabled because <div> element has checkbox
input and label elements as children that allows keyboard interaction.
The onClick handler facilitates consumers' ability to stop click events
from bubbling beyond the checkbox without having to implement their own
wrapper element around <Checkbox>.
*/
/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
<div className={wrapperClasses} onClick={(evt) => onClick(evt)}>
<div className={wrapperClasses}>
<input
{...other}
type="checkbox"
Expand Down Expand Up @@ -132,14 +123,6 @@ Checkbox.propTypes = {
*/
onChange: PropTypes.func,

/**
* Provide an optional click handler that is applied to the wrapper div
* containing both the input and the span label. As such, this will be
* called twice for every click - once for the input, a second time for the label.
* Receives the dom event as its only argument.
*/
onClick: PropTypes.func,

/**
* Specify a title for the <label> node for the Checkbox
*/
Expand All @@ -156,7 +139,6 @@ Checkbox.propTypes = {

Checkbox.defaultProps = {
onChange: () => {},
onClick: () => {},
indeterminate: false,
};

Expand Down

0 comments on commit 3bdf29b

Please sign in to comment.