mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 21:19:37 +08:00
fix: tooltip should work with loading switch (#33860)
* fix: tooltip should work with loading switch * fix: only works for switch * chore: code clean
This commit is contained in:
parent
9fe57c654a
commit
2d66c7ecc6
@ -346,4 +346,22 @@ describe('Tooltip', () => {
|
|||||||
);
|
);
|
||||||
expect(wrapper.find('.ant-tooltip-inner').getDOMNode().style.color).toBe('red');
|
expect(wrapper.find('.ant-tooltip-inner').getDOMNode().style.color).toBe('red');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should work with loading switch', () => {
|
||||||
|
const onVisibleChange = jest.fn();
|
||||||
|
const wrapper = mount(
|
||||||
|
<Tooltip
|
||||||
|
title="loading tips"
|
||||||
|
mouseEnterDelay={0}
|
||||||
|
mouseLeaveDelay={0}
|
||||||
|
onVisibleChange={onVisibleChange}
|
||||||
|
>
|
||||||
|
<Switch loading defaultChecked />
|
||||||
|
</Tooltip>,
|
||||||
|
);
|
||||||
|
const wrapperEl = wrapper.find('.ant-tooltip-disabled-compatible-wrapper');
|
||||||
|
expect(wrapperEl).toHaveLength(1);
|
||||||
|
wrapper.find('span').first().simulate('mouseenter');
|
||||||
|
expect(onVisibleChange).toHaveBeenLastCalledWith(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -85,10 +85,8 @@ const PresetColorRegex = new RegExp(`^(${PresetColorTypes.join('|')})(-inverse)?
|
|||||||
function getDisabledCompatibleChildren(element: React.ReactElement<any>, prefixCls: string) {
|
function getDisabledCompatibleChildren(element: React.ReactElement<any>, prefixCls: string) {
|
||||||
const elementType = element.type as any;
|
const elementType = element.type as any;
|
||||||
if (
|
if (
|
||||||
(elementType.__ANT_BUTTON === true ||
|
((elementType.__ANT_BUTTON === true || element.type === 'button') && element.props.disabled) ||
|
||||||
elementType.__ANT_SWITCH === true ||
|
(elementType.__ANT_SWITCH === true && (element.props.disabled || element.props.loading))
|
||||||
element.type === 'button') &&
|
|
||||||
element.props.disabled
|
|
||||||
) {
|
) {
|
||||||
// Pick some layout related style properties up to span
|
// Pick some layout related style properties up to span
|
||||||
// Prevent layout bugs like https://github.com/ant-design/ant-design/issues/5254
|
// Prevent layout bugs like https://github.com/ant-design/ant-design/issues/5254
|
||||||
|
Loading…
Reference in New Issue
Block a user