fix: inconsistency between checkbox and radio in table when Form is disabled (#40728)

This commit is contained in:
JiaQi 2023-02-15 13:21:53 +08:00 committed by GitHub
parent 41d9efd29f
commit 910d0fc340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import React from 'react';
import Radio, { Button, Group } from '..';
import Form from '../../form';
import focusTest from '../../../tests/shared/focusTest';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
@ -33,4 +34,15 @@ describe('Radio', () => {
fireEvent.mouseLeave(container.querySelector('label')!);
expect(onMouseLeave).toHaveBeenCalled();
});
it('should use own disabled status first', () => {
const { container } = render(
<Form disabled>
<Radio disabled={false} />
</Form>,
);
expect(container.querySelector('.ant-radio-wrapper')).not.toHaveClass(
'ant-radio-wrapper-disabled',
);
});
});

View File

@ -49,7 +49,7 @@ const InternalRadio: React.ForwardRefRenderFunction<HTMLElement, RadioProps> = (
// ===================== Disabled =====================
const disabled = React.useContext(DisabledContext);
radioProps.disabled = customDisabled || disabled;
radioProps.disabled = customDisabled ?? disabled;
if (groupContext) {
radioProps.name = groupContext.name;