From 6dd39c1f89b4d6632e6ed022ff1bc275ca1e0f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=B5=A9?= Date: Thu, 20 Jan 2022 19:23:14 +0800 Subject: [PATCH] fix(checkbox): disabled checkbox should works well with tooltip (#33772) Co-authored-by: wanghao --- components/checkbox/style/mixin.less | 1 + .../__snapshots__/tooltip.test.js.snap | 26 ------------------- components/tooltip/__tests__/tooltip.test.js | 2 -- components/tooltip/index.tsx | 9 ++++--- 4 files changed, 6 insertions(+), 32 deletions(-) diff --git a/components/checkbox/style/mixin.less b/components/checkbox/style/mixin.less index 60c8201a5e..c16a3f091a 100644 --- a/components/checkbox/style/mixin.less +++ b/components/checkbox/style/mixin.less @@ -122,6 +122,7 @@ .@{checkbox-prefix-cls}-input { cursor: not-allowed; + pointer-events: none; } .@{checkbox-inner-prefix-cls} { diff --git a/components/tooltip/__tests__/__snapshots__/tooltip.test.js.snap b/components/tooltip/__tests__/__snapshots__/tooltip.test.js.snap index 718c3d35ee..776998c5f7 100644 --- a/components/tooltip/__tests__/__snapshots__/tooltip.test.js.snap +++ b/components/tooltip/__tests__/__snapshots__/tooltip.test.js.snap @@ -16,32 +16,6 @@ exports[`Tooltip should hide when mouse leave antd disabled component Button 1`] `; -exports[`Tooltip should hide when mouse leave antd disabled component Checkbox 1`] = ` - - - -`; - exports[`Tooltip should hide when mouse leave antd disabled component Switch 1`] = ` { testComponent('Button', Button); testComponent('Switch', Switch); - testComponent('Checkbox', Checkbox); }); it('should render disabled Button style properly', () => { diff --git a/components/tooltip/index.tsx b/components/tooltip/index.tsx index 8842bb7c84..ee5beaf753 100644 --- a/components/tooltip/index.tsx +++ b/components/tooltip/index.tsx @@ -87,7 +87,6 @@ function getDisabledCompatibleChildren(element: React.ReactElement, prefixC if ( (elementType.__ANT_BUTTON === true || elementType.__ANT_SWITCH === true || - elementType.__ANT_CHECKBOX === true || element.type === 'button') && element.props.disabled ) { @@ -130,9 +129,11 @@ function getDisabledCompatibleChildren(element: React.ReactElement, prefixC } const Tooltip = React.forwardRef((props, ref) => { - const { getPopupContainer: getContextPopupContainer, getPrefixCls, direction } = React.useContext( - ConfigContext, - ); + const { + getPopupContainer: getContextPopupContainer, + getPrefixCls, + direction, + } = React.useContext(ConfigContext); const [visible, setVisible] = useMergedState(false, { value: props.visible,