Browse Source

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

pull/24386/head
Kermit Xuan 5 years ago
committed by GitHub
parent
commit
b57d306107
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      components/tooltip/__tests__/__snapshots__/demo.test.js.snap
  2. 25
      components/tooltip/demo/destroy-tooltip-on-hide.md
  3. 1
      components/tooltip/index.en-US.md
  4. 1
      components/tooltip/index.zh-CN.md
  5. 2
      package.json

6
components/tooltip/__tests__/__snapshots__/demo.test.js.snap

@ -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"

25
components/tooltip/demo/destroy-tooltip-on-hide.md

@ -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,
);
```

1
components/tooltip/index.en-US.md

@ -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

1
components/tooltip/index.zh-CN.md

@ -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 | |
## 注意

2
package.json

@ -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",

Loading…
Cancel
Save