Skip to content

Commit

Permalink
[IE only] Address an issue that the change event never fires for `i…
Browse files Browse the repository at this point in the history
…ndeterminate` input elements
  • Loading branch information
cheton committed May 22, 2018
1 parent 727b4bd commit 6a2fba9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ checked | Boolean | | The checked state of the checkbox element.
defaultChecked | Boolean | | The default checked state of the checkbox element.
indeterminate | Boolean | | The indeterminate state of the checkbox element.
defaultIndeterminate | Boolean | false | The default indeterminate state of the checkbox element.
onChange | Function(event) | | The callback function that is triggered when the state changes.
onClick | Function(event) | | The callback function that is triggered when the checkbox is clicked.

#### CheckboxGroup

Expand All @@ -157,7 +159,7 @@ disabled | Boolean | false | If true, the checkbox group will be displayed as di
name | String | | Name for the input element group.
value | any | | The value of the checkbox group.
defaultValue | any | | The default value of the checkbox group.
onChange | Function | | Callback function that will be invoked when the value changes.
onChange | Function(value, event) | | The callback function that is triggered when the value changes.
depth | Number | 1 | Limits the recursion depth when rendering checkboxes deeply inside a checkbox group.

### Class Properties
Expand Down
13 changes: 8 additions & 5 deletions src/Checkbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class Checkbox extends PureComponent {
defaultChecked: PropTypes.bool,
indeterminate: PropTypes.bool,
defaultIndeterminate: PropTypes.bool,
onChange: PropTypes.func
onChange: PropTypes.func,
onClick: PropTypes.func
};

static defaultProps = {
Expand All @@ -29,7 +30,7 @@ class Checkbox extends PureComponent {

checkbox = null;

onChange = (event) => {
updateIndeterminateState = () => {
if (typeof (this.props.indeterminate) !== 'undefined') {
this.checkbox.indeterminate = !!this.props.indeterminate;
}
Expand Down Expand Up @@ -57,6 +58,7 @@ class Checkbox extends PureComponent {
disabled,
defaultIndeterminate,
onChange = noop,
onClick = noop,

// Default props
className,
Expand Down Expand Up @@ -90,9 +92,10 @@ class Checkbox extends PureComponent {
styles.inputCheckbox
)}
style={inputStyle}
onChange={chainedFunction(
this.onChange,
onChange
onChange={onChange}
onClick={chainedFunction(
this.updateIndeterminateState,
onClick
)}
/>
<i className={styles.controlIndicator} />
Expand Down

0 comments on commit 6a2fba9

Please sign in to comment.