Browse Source

Revert "Checkbox[disabled] should have higher priority than Checkbox.Group[disabled]"

This reverts commit 5580791a70.
pull/10009/head
Wei Zhu 7 years ago
parent
commit
f9b8bf7e4d
  1. 2
      components/checkbox/Checkbox.tsx
  2. 11
      components/checkbox/__tests__/group.test.js

2
components/checkbox/Checkbox.tsx

@ -86,7 +86,7 @@ export default class Checkbox extends React.Component<CheckboxProps, {}> {
if (checkboxGroup) {
checkboxProps.onChange = () => checkboxGroup.toggleOption({ label: children, value: props.value });
checkboxProps.checked = checkboxGroup.value.indexOf(props.value) !== -1;
checkboxProps.disabled = 'disabled' in props ? props.disabled : checkboxGroup.disabled;
checkboxProps.disabled = props.disabled || checkboxGroup.disabled;
}
const classString = classNames(className, {
[`${prefixCls}-wrapper`]: true,

11
components/checkbox/__tests__/group.test.js

@ -51,15 +51,4 @@ describe('CheckboxGroup', () => {
groupWrapper.find('.ant-checkbox-input').at(1).simulate('change');
expect(onChangeGroup).toBeCalledWith(['Apple']);
});
it('Checkbox[disabled] should have higher priority than Group[disabled]', () => {
const options = [
{ label: 'Apple', value: 'Apple' },
{ label: 'Orange', value: 'Orange', disabled: false },
];
const wrapper = mount(
<Checkbox.Group options={options} disabled />
);
expect(wrapper.find('input').at(1).props().disabled).toBe(false);
});
});

Loading…
Cancel
Save