fix: tooltip should work with loading switch

pull/5361/head
tangjinzhou 2022-03-17 15:10:28 +08:00
parent 2b81a7213b
commit 625efff1fa
1 changed files with 46 additions and 44 deletions

View File

@ -136,16 +136,17 @@ export default defineComponent({
})
);
});
const isTrueProps = (val: boolean | '') => {
return val || val === '';
};
const getDisabledCompatibleChildren = (ele: any) => {
const elementType = ele.type as any;
if (typeof elementType === 'object' && ele.props) {
if (
((typeof ele.type === 'object' &&
(ele.type.__ANT_BUTTON === true ||
ele.type.__ANT_SWITCH === true ||
ele.type.__ANT_CHECKBOX === true)) ||
ele.type === 'button') &&
ele.props &&
(ele.props.disabled || ele.props.disabled === '')
((elementType.__ANT_BUTTON === true || elementType === 'button') &&
isTrueProps(ele.props.disabled)) ||
(elementType.__ANT_SWITCH === true &&
(isTrueProps(ele.props.disabled) || isTrueProps(ele.props.loading)))
) {
// Pick some layout related style properties up to span
// Prevent layout bugs like https://github.com/ant-design/ant-design/issues/5254
@ -182,6 +183,7 @@ export default defineComponent({
</span>
);
}
}
return ele;
};