Skip to content

Commit

Permalink
docs: add faq
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Sep 22, 2023
1 parent c09b170 commit 5cda9a1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
23 changes: 23 additions & 0 deletions components/tooltip/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,26 @@ It will follow `placement` config when screen has enough space. And flip when sp
<img alt="shift" height="200" src="https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*sxaTTJjLtIMAAAAAAAAAAAAADrJ8AQ/original" />

When `placement` is set to edge align such as `topLeft` `bottomRight`, it will only do flip but not do shift.

### Why Tooltip not update content when close?

Tooltip will cache content when it is closed to avoid flicker when content is updated:

```jsx
// `title` will not blink when `user` is empty
<Tooltip open={user} title={user?.name} />
```
<div>
<img alt="no blink" height="50" src="https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*KVx7QLOYwVsAAAAAAAAAAAAADrJ8AQ/original" />
</div>
If need update content when close, you can set `fresh` property:
```jsx
<Tooltip open={user} title={user?.name} fresh />
```
<div>
<img alt="no blink" height="50" src="https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*rUbsR4xWpMsAAAAAAAAAAAAADrJ8AQ/original" />
</div>
12 changes: 10 additions & 2 deletions components/tooltip/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,19 @@ Tooltip 默认在关闭时会缓存内容,以防止内容更新时出现闪烁

```jsx
// `title` 不会因为 `user` 置空而闪烁置空
<Tooltip open={!user} title={user?.name} />
<Tooltip open={user} title={user?.name} />
```
<div>
<img alt="no blink" height="50" src="https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*KVx7QLOYwVsAAAAAAAAAAAAADrJ8AQ/original" />
</div>
如果需要在关闭时也更新内容,可以设置 `fresh` 属性:
```jsx
<Tooltip open={!user} title={user?.name} fresh />
<Tooltip open={user} title={user?.name} fresh />
```
<div>
<img alt="no blink" height="50" src="https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*rUbsR4xWpMsAAAAAAAAAAAAADrJ8AQ/original" />
</div>

0 comments on commit 5cda9a1

Please sign in to comment.