Skip to content

Commit

Permalink
fix: Checkbox disabled should support Tooltip (#39829)
Browse files Browse the repository at this point in the history
* docs: update demo

* test: Update snapshot
  • Loading branch information
zombieJ committed Dec 26, 2022
1 parent 5ea90df commit ff92370
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 0 deletions.
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

0 comments on commit ff92370

Please sign in to comment.