Skip to content

Commit 6a2fba9

Browse files
committed
[IE only] Address an issue that the change event never fires for indeterminate input elements
1 parent 727b4bd commit 6a2fba9

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ checked | Boolean | | The checked state of the checkbox element.
147147
defaultChecked | Boolean | | The default checked state of the checkbox element.
148148
indeterminate | Boolean | | The indeterminate state of the checkbox element.
149149
defaultIndeterminate | Boolean | false | The default indeterminate state of the checkbox element.
150+
onChange | Function(event) | | The callback function that is triggered when the state changes.
151+
onClick | Function(event) | | The callback function that is triggered when the checkbox is clicked.
150152

151153
#### CheckboxGroup
152154

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

163165
### Class Properties

src/Checkbox.jsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class Checkbox extends PureComponent {
1919
defaultChecked: PropTypes.bool,
2020
indeterminate: PropTypes.bool,
2121
defaultIndeterminate: PropTypes.bool,
22-
onChange: PropTypes.func
22+
onChange: PropTypes.func,
23+
onClick: PropTypes.func
2324
};
2425

2526
static defaultProps = {
@@ -29,7 +30,7 @@ class Checkbox extends PureComponent {
2930

3031
checkbox = null;
3132

32-
onChange = (event) => {
33+
updateIndeterminateState = () => {
3334
if (typeof (this.props.indeterminate) !== 'undefined') {
3435
this.checkbox.indeterminate = !!this.props.indeterminate;
3536
}
@@ -57,6 +58,7 @@ class Checkbox extends PureComponent {
5758
disabled,
5859
defaultIndeterminate,
5960
onChange = noop,
61+
onClick = noop,
6062

6163
// Default props
6264
className,
@@ -90,9 +92,10 @@ class Checkbox extends PureComponent {
9092
styles.inputCheckbox
9193
)}
9294
style={inputStyle}
93-
onChange={chainedFunction(
94-
this.onChange,
95-
onChange
95+
onChange={onChange}
96+
onClick={chainedFunction(
97+
this.updateIndeterminateState,
98+
onClick
9699
)}
97100
/>
98101
<i className={styles.controlIndicator} />

0 commit comments

Comments
 (0)