mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
fix: inconsistency between checkbox and radio in table when Form is disabled (#40728)
This commit is contained in:
parent
41d9efd29f
commit
910d0fc340
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Radio, { Button, Group } from '..';
|
import Radio, { Button, Group } from '..';
|
||||||
|
import Form from '../../form';
|
||||||
import focusTest from '../../../tests/shared/focusTest';
|
import focusTest from '../../../tests/shared/focusTest';
|
||||||
import mountTest from '../../../tests/shared/mountTest';
|
import mountTest from '../../../tests/shared/mountTest';
|
||||||
import rtlTest from '../../../tests/shared/rtlTest';
|
import rtlTest from '../../../tests/shared/rtlTest';
|
||||||
@ -33,4 +34,15 @@ describe('Radio', () => {
|
|||||||
fireEvent.mouseLeave(container.querySelector('label')!);
|
fireEvent.mouseLeave(container.querySelector('label')!);
|
||||||
expect(onMouseLeave).toHaveBeenCalled();
|
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',
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -49,7 +49,7 @@ const InternalRadio: React.ForwardRefRenderFunction<HTMLElement, RadioProps> = (
|
|||||||
|
|
||||||
// ===================== Disabled =====================
|
// ===================== Disabled =====================
|
||||||
const disabled = React.useContext(DisabledContext);
|
const disabled = React.useContext(DisabledContext);
|
||||||
radioProps.disabled = customDisabled || disabled;
|
radioProps.disabled = customDisabled ?? disabled;
|
||||||
|
|
||||||
if (groupContext) {
|
if (groupContext) {
|
||||||
radioProps.name = groupContext.name;
|
radioProps.name = groupContext.name;
|
||||||
|
Loading…
Reference in New Issue
Block a user