Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Checkbox disabled should support Tooltip #39829

Merged
merged 2 commits into from Dec 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -159,6 +159,58 @@ Array [
]
`;

exports[`renders ./components/checkbox/demo/debug-disable-popover.tsx extend context correctly 1`] = `
<div
style="padding:56px"
>
<label
class="ant-checkbox-wrapper ant-checkbox-wrapper-checked ant-checkbox-wrapper-disabled"
>
<span
class="ant-checkbox ant-checkbox-checked ant-checkbox-disabled"
>
<input
checked=""
class="ant-checkbox-input"
disabled=""
type="checkbox"
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
<div>
<div
class="ant-popover"
style="opacity:0"
>
<div
class="ant-popover-content"
>
<div
class="ant-popover-arrow"
>
<span
class="ant-popover-arrow-content"
/>
</div>
<div
class="ant-popover-inner"
role="tooltip"
>
<div
class="ant-popover-inner-content"
>
xxxx
</div>
</div>
</div>
</div>
</div>
</div>
`;

exports[`renders ./components/checkbox/demo/debug-line.tsx extend context correctly 1`] = `
<div>
<div
Expand Down
24 changes: 24 additions & 0 deletions components/checkbox/__tests__/__snapshots__/demo.test.ts.snap
Expand Up @@ -159,6 +159,30 @@ Array [
]
`;

exports[`renders ./components/checkbox/demo/debug-disable-popover.tsx correctly 1`] = `
<div
style="padding:56px"
>
<label
class="ant-checkbox-wrapper ant-checkbox-wrapper-checked ant-checkbox-wrapper-disabled"
>
<span
class="ant-checkbox ant-checkbox-checked ant-checkbox-disabled"
>
<input
checked=""
class="ant-checkbox-input"
disabled=""
type="checkbox"
/>
<span
class="ant-checkbox-inner"
/>
</span>
</label>
</div>
`;

exports[`renders ./components/checkbox/demo/debug-line.tsx correctly 1`] = `
<div>
<div
Expand Down
7 changes: 7 additions & 0 deletions components/checkbox/demo/debug-disable-popover.md
@@ -0,0 +1,7 @@
## zh-CN

禁用时鼠标进入、离开触发 Tooltip

## en-US

Disable to show/hide Tooltip
12 changes: 12 additions & 0 deletions components/checkbox/demo/debug-disable-popover.tsx
@@ -0,0 +1,12 @@
import React from 'react';
import { Checkbox, Popover } from 'antd';

const App: React.FC = () => (
<div style={{ padding: 56 }}>
<Popover content="xxxx" trigger="hover">
<Checkbox disabled checked />
</Popover>
</div>
);

export default App;
1 change: 1 addition & 0 deletions components/checkbox/index.en-US.md
Expand Up @@ -24,6 +24,7 @@ Checkbox component.
<code src="./demo/check-all.tsx">Check all</code>
<code src="./demo/layout.tsx">Use with Grid</code>
<code src="./demo/debug-line.tsx" debug>Same line</code>
<code src="./demo/debug-disable-popover.tsx" debug>Disabled to show Tooltip</code>

## API

Expand Down
1 change: 1 addition & 0 deletions components/checkbox/index.zh-CN.md
Expand Up @@ -25,6 +25,7 @@ demo:
<code src="./demo/check-all.tsx">全选</code>
<code src="./demo/layout.tsx">布局</code>
<code src="./demo/debug-line.tsx" debug>同行布局</code>
<code src="./demo/debug-disable-popover.tsx" debug>禁用下的 Tooltip</code>

## API

Expand Down
3 changes: 3 additions & 0 deletions components/checkbox/style/index.tsx
Expand Up @@ -246,6 +246,9 @@ export const genCheckboxStyle: GenerateStyle<CheckboxToken> = (token) => {
// Wrapper > Checkbox > input
[`&, ${checkboxCls}-input`]: {
cursor: 'not-allowed',
// Disabled for native input to enable Tooltip event handler
// ref: https://github.com/ant-design/ant-design/issues/39822#issuecomment-1365075901
pointerEvents: 'none',
},

// Wrapper > Checkbox > inner
Expand Down