feat: optmize tooptip destroyTooltipOnHide (#19536) (#24362)

This commit is contained in:
Kermit Xuan 2020-05-22 00:20:01 +08:00 committed by GitHub
parent b467cc5cbb
commit b57d306107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 1 deletions

View File

@ -51,6 +51,12 @@ exports[`renders ./components/tooltip/demo/basic.md correctly 1`] = `
</span>
`;
exports[`renders ./components/tooltip/demo/destroy-tooltip-on-hide.md correctly 1`] = `
<span>
Tooltip will destroy when hidden.
</span>
`;
exports[`renders ./components/tooltip/demo/placement.md correctly 1`] = `
<div
class="demo"

View File

@ -0,0 +1,25 @@
---
order: 4
title:
zh-CN: 隐藏后销毁
en-US: Destroy tooltip when hidden
---
## zh-CN
通过 `destroyTooltipOnHide` 控制提示关闭时是否销毁 dom 节点。
## en-US
Setting `destroyTooltipOnHide` to control whether destroy dom node of tooltip when hidden.
```jsx
import { Tooltip } from 'antd';
ReactDOM.render(
<Tooltip destroyTooltipOnHide={{ keepParent: false }} title="prompt text">
<span>Tooltip will destroy when hidden.</span>
</Tooltip>,
mountNode,
);
```

View File

@ -36,6 +36,7 @@ The following APIs are shared by Tooltip, Popconfirm, Popover.
| visible | Whether the floating tooltip card is visible or not | boolean | `false` | |
| onVisibleChange | Callback executed when visibility of the tooltip card is changed | (visible) => void | - | |
| align | this value will be merged into placement's config, please refer to the settings [rc-tooltip](https://github.com/react-component/tooltip) | Object | - | |
| destroyTooltipOnHide | whether destroy tooltip when hidden, parent container of tooltip will be destroyed when `keepParent` is `false` | boolean \| { keepParent?: boolean } | false | |
## Note

View File

@ -38,6 +38,7 @@ title: Tooltip
| visible | 用于手动控制浮层显隐 | boolean | false | |
| onVisibleChange | 显示隐藏的回调 | (visible) => void | 无 | |
| align | 该值将合并到 placement 的配置中,设置参考 [rc-tooltip](https://github.com/react-component/tooltip) | Object | 无 | |
| destroyTooltipOnHide | 关闭后是否销毁 Tooltip`keepParent``false` 时销毁父容器 | boolean \| { keepParent?: boolean } | false | |
## 注意

View File

@ -137,7 +137,7 @@
"rc-switch": "~3.1.0",
"rc-table": "~7.7.0",
"rc-tabs": "~10.1.1",
"rc-tooltip": "~4.0.2",
"rc-tooltip": "~4.1.0",
"rc-tree": "~3.2.0",
"rc-tree-select": "~3.1.0",
"rc-trigger": "~4.1.0",