CheckboxGroup onChange 值保持选项的顺序

This commit is contained in:
yoyo837 2019-06-27 18:54:34 +08:00
parent 4463d24660
commit 32bb62be15

View File

@ -136,7 +136,9 @@ class CheckboxGroup extends React.Component<CheckboxGroupProps, CheckboxGroupSta
}
const onChange = this.props.onChange;
if (onChange) {
onChange(value.filter(val => registeredValues.indexOf(val) !== -1));
const values = value.filter(val => registeredValues.indexOf(val) !== -1);
const options = this.getOptions();
onChange(options.map(opt => values.includes(opt.value)));
}
};