fix(checkbox): disabled checkbox should works well with tooltip (#33772)

Co-authored-by: wanghao <wanghao.wong@bytedance.com>
This commit is contained in:
王浩 2022-01-20 19:23:14 +08:00 committed by GitHub
parent 3c76de74ce
commit 6dd39c1f89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 32 deletions

View File

@ -122,6 +122,7 @@
.@{checkbox-prefix-cls}-input {
cursor: not-allowed;
pointer-events: none;
}
.@{checkbox-inner-prefix-cls} {

View File

@ -16,32 +16,6 @@ exports[`Tooltip should hide when mouse leave antd disabled component Button 1`]
</span>
`;
exports[`Tooltip should hide when mouse leave antd disabled component Checkbox 1`] = `
<span
class="ant-tooltip-disabled-compatible-wrapper"
style="display: inline-block; cursor: not-allowed;"
>
<label
class="ant-checkbox-wrapper ant-checkbox-wrapper-disabled"
style="pointer-events: none;"
>
<span
class="ant-checkbox ant-checkbox-disabled"
>
<input
class="ant-checkbox-input"
disabled=""
type="checkbox"
value=""
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
</span>
`;
exports[`Tooltip should hide when mouse leave antd disabled component Switch 1`] = `
<span
class="ant-tooltip-disabled-compatible-wrapper"

View File

@ -4,7 +4,6 @@ import { spyElementPrototype } from 'rc-util/lib/test/domHook';
import Tooltip from '..';
import Button from '../../button';
import Switch from '../../switch';
import Checkbox from '../../checkbox';
import DatePicker from '../../date-picker';
import Input from '../../input';
import Group from '../../input/Group';
@ -131,7 +130,6 @@ describe('Tooltip', () => {
testComponent('Button', Button);
testComponent('Switch', Switch);
testComponent('Checkbox', Checkbox);
});
it('should render disabled Button style properly', () => {

View File

@ -87,7 +87,6 @@ function getDisabledCompatibleChildren(element: React.ReactElement<any>, 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<any>, prefixC
}
const Tooltip = React.forwardRef<unknown, TooltipProps>((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,