diff --git a/components/radio/index.tsx b/components/radio/index.tsx index 502e478269..c164867fcc 100644 --- a/components/radio/index.tsx +++ b/components/radio/index.tsx @@ -18,9 +18,11 @@ interface CompoundedComponent extends React.ForwardRefExoticComponent> { Group: typeof Group; Button: typeof Button; + __ANT_RADIO: boolean; } const Radio = InternalRadio as CompoundedComponent; Radio.Button = Button; Radio.Group = Group; +Radio.__ANT_RADIO = true; export default Radio; diff --git a/components/tooltip/__tests__/tooltip.test.js b/components/tooltip/__tests__/tooltip.test.js index 9df5714fc4..62129cd42f 100644 --- a/components/tooltip/__tests__/tooltip.test.js +++ b/components/tooltip/__tests__/tooltip.test.js @@ -9,6 +9,7 @@ import DatePicker from '../../date-picker'; import Input from '../../input'; import Group from '../../input/Group'; import Switch from '../../switch'; +import Radio from '../../radio'; describe('Tooltip', () => { mountTest(Tooltip); @@ -402,4 +403,23 @@ describe('Tooltip', () => { expect(onVisibleChange).toHaveBeenLastCalledWith(true); expect(container.querySelector('.ant-tooltip-open')).not.toBeNull(); }); + + it('should work with disabled Radio', () => { + const onVisibleChange = jest.fn(); + const { container } = render( + + + , + ); + const wrapperEl = container.querySelectorAll('.ant-tooltip-disabled-compatible-wrapper'); + expect(wrapperEl).toHaveLength(1); + fireEvent.mouseEnter(container.getElementsByTagName('span')[0]); + expect(onVisibleChange).toHaveBeenLastCalledWith(true); + expect(container.querySelector('.ant-tooltip-open')).not.toBeNull(); + }); }); diff --git a/components/tooltip/index.tsx b/components/tooltip/index.tsx index f72e300fbf..b60f3f8681 100644 --- a/components/tooltip/index.tsx +++ b/components/tooltip/index.tsx @@ -87,7 +87,8 @@ function getDisabledCompatibleChildren(element: React.ReactElement, prefixC const elementType = element.type as any; if ( ((elementType.__ANT_BUTTON === true || element.type === 'button') && element.props.disabled) || - (elementType.__ANT_SWITCH === true && (element.props.disabled || element.props.loading)) + (elementType.__ANT_SWITCH === true && (element.props.disabled || element.props.loading)) || + (elementType.__ANT_RADIO === true && element.props.disabled) ) { // Pick some layout related style properties up to span // Prevent layout bugs like https://github.com/ant-design/ant-design/issues/5254