Skip to content

Fix the problem that the Slider's Tooltip is in the incorrect position when use modal #16717

Merged
zombieJ merged 8 commits intoant-design:masterfrom
ztplz:slider
May 26, 2019
Merged

Fix the problem that the Slider's Tooltip is in the incorrect position when use modal #16717
zombieJ merged 8 commits intoant-design:masterfrom
ztplz:slider

Conversation

@ztplz
Copy link
Contributor

@ztplz ztplz commented May 21, 2019

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / document update
  • Component style update
  • TypeScript definition update
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

👻 What's the background?

close #13416
close #13418
close #16669

💡 Solution

📝 Changelog

Language Changelog
🇺🇸 English
Fix the problem that the Slider's Tooltip is in the incorrect position when use modal
🇨🇳 Chinese
修复在使用Slider的时候设置了tooltipVisible显示 但是切换了tab后tooltip的定位会错乱的问题

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

IssueHunt Summary

Referenced issues

This pull request has been submitted to:


@ztplz
Copy link
Contributor Author

ztplz commented May 21, 2019

ref: #16669

@ztplz ztplz requested review from afc163 and zombieJ May 21, 2019 16:24
@ztplz ztplz changed the title Slider Fix the problem that the Slider's Tooltip is in the incorrect position when use modal May 21, 2019
@netlify
Copy link

netlify bot commented May 21, 2019

Deploy preview for ant-design ready!

Built with commit 951b03f

https://deploy-preview-16717--ant-design.netlify.com

@codecov
Copy link

codecov bot commented May 21, 2019

Codecov Report

Merging #16717 into master will decrease coverage by 0.05%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16717      +/-   ##
==========================================
- Coverage   95.75%    95.7%   -0.06%     
==========================================
  Files         258      258              
  Lines        7140     7142       +2     
  Branches     1974     1999      +25     
==========================================
- Hits         6837     6835       -2     
- Misses        301      305       +4     
  Partials        2        2
Impacted Files Coverage Δ
components/slider/index.tsx 86.48% <50%> (-2.09%) ⬇️
components/_util/wave.tsx 85.84% <0%> (-2.84%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55bd82d...4f05552. Read the comment docs.

@codecov
Copy link

codecov bot commented May 21, 2019

Codecov Report

Merging #16717 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16717      +/-   ##
==========================================
+ Coverage   95.75%   95.75%   +<.01%     
==========================================
  Files         258      258              
  Lines        7140     7141       +1     
  Branches     1974     1974              
==========================================
+ Hits         6837     6838       +1     
  Misses        301      301              
  Partials        2        2
Impacted Files Coverage Δ
components/slider/index.tsx 88.88% <100%> (+0.31%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55bd82d...951b03f. Read the comment docs.

placement="top"
transitionName="zoom-down"
key={index}
getPopupContainer={() => (this.tooltipRef ? this.tooltipRef.current.handle : document.body)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

默认还是应该放在 body 里的,加个 getTooltipPopupContainer 属性让用户自己修改吧~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不用啊 这是特殊场景 应该放在handle这里的 我这里函数没有必要 直接三目就好了

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/react-component/* 那一套没点时间真的不熟悉 🙃

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

popup 放在外面是为了防止样式污染,以及外部容器如果用了 overflow: hidden 显示不全。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那要写个example啊 不然用户要看代码才能知道那个ref是什么

@ztplz
Copy link
Contributor Author

ztplz commented May 23, 2019

@zombieJ 用户要么加个元素挂上去 要么就挂在slider的ref上 这个要看代码的 我把slider的ref public了

id?: string;
style?: React.CSSProperties;
tooltipVisible?: boolean;
getTooltipPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加到 rc-slider 里去吧,那里也有类似的问题。

react-component/slider#564
react-component/slider#374

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rc-slider怎么有一个createSliderWithTooltip

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 Tooltip 是包裹 Slider Handle 出来的,不是 rc-slider 的 bug。这个 PR 合进去后,指引过来就行了。

Copy link
Contributor Author

@ztplz ztplz May 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边怎么没复用rc-slider那边

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是挺神奇的,估计是用于包裹 antd 的 Tooltip 来统一样式。 @afc163 看看我猜的对不对……

@zombieJ
Copy link
Member

zombieJ commented May 23, 2019

文档更新一下~

@ztplz
Copy link
Contributor Author

ztplz commented May 24, 2019

@zombieJ 啥文档

@zombieJ
Copy link
Member

zombieJ commented May 24, 2019

index.zh-CN.mdindex.en-US.md 加一下 getTooltipPopupContainer 哈~

| onAfterChange | 与 `onmouseup` 触发时机一致,把当前值作为参数传入。 | Function(value) | NOOP |
| onChange | 当 Slider 的值发生改变时,会触发 onChange 事件,并把改变后的值作为参数传入。 | Function(value) | NOOP |
| tooltipVisible | 值为`true`时,Tooltip 将会始终显示;否则始终不显示,哪怕在拖拽及移入时。 | Boolean | |
| getTooltipPopupContainer | 浮层渲染父节点,默认渲染到 body 上。 | Function | () => document.body |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要写清楚是 Tooltip 的渲染节点。

Copy link
Contributor Author

@ztplz ztplz May 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个从其他组件copy过来的 忘记改了

@ztplz
Copy link
Contributor Author

ztplz commented May 24, 2019

ci挂了?

@zombieJ
Copy link
Member

zombieJ commented May 26, 2019

feature branch

@afc163 afc163 mentioned this pull request May 26, 2019
10 tasks
@zombieJ zombieJ merged commit 9793e30 into ant-design:master May 26, 2019
@ztplz ztplz deleted the slider branch May 27, 2019 07:01
@HuaileiW
Copy link

HuaileiW commented Jun 4, 2019

想知道为什么在tooltipVisible=true的情况下 会挂在body上? 如果不放在body上 是不是就不需要getTooltipPopupContainer这个了。

@zombieJ
Copy link
Member

zombieJ commented Jun 4, 2019

默认 popup 都在 body 上,是为了防止样式影响以及如果父容器有 overflow: hidden 后导致popup 展示不全的问题。

@github-actions
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants