Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(components): [tooltip] display tooltip correctly #11643

Merged
merged 6 commits into from
Feb 22, 2023

Conversation

acyza
Copy link
Contributor

@acyza acyza commented Feb 18, 2023

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.

fix #11629

图片

这top-end明显比其他的矮一节。

@pull-request-triage
Copy link

👋 @acyza, thank you for contributing element-plus.

  • You can comment with /label Components:[component_name] to add a label for which component you are working on.
  • You may join our Discord for staying tuned.

@github-actions
Copy link

Hello @acyza, thank you for contributing to element-plus, please see our guideline to see how to make contribution

@github-actions
Copy link

github-actions bot commented Feb 18, 2023

@github-actions
Copy link

github-actions bot commented Feb 18, 2023

🧪 Playground Preview: https://element-plus.run/?pr=11643
Please comment the example via this playground if needed.

@acyza
Copy link
Contributor Author

acyza commented Feb 18, 2023

@jw-foss 这个left:0,right:0其什么作用吗?可以去掉right:0吗?因为其初始宽度过宽tooltip在placement=top-end时计算过程中产生了不必要的横向滚动条,但最终的效果可能没有这个滚动条,导致像chrome那样滚动条占空间的浏览器计算的结果有偏差,去掉right:0让其宽度适应内容似乎可以解决这个问题。
相关pr:#10983
相关issue: #11629

@acyza
Copy link
Contributor Author

acyza commented Feb 18, 2023

简单测了下popover,tooltip,dropdown,select组件暂时没发现有啥问题。

@acyza
Copy link
Contributor Author

acyza commented Feb 22, 2023

要研究tooltip的定位过程可以通过devtools在popper.js的forceupdate函数结尾打断点,观察每次forceupdate结束tooltip的inset(left,top,right,bottom),transform样式的值。
另外如果right:0不能去掉也可以多调用几次update让它更新到正确位置。

@acyza
Copy link
Contributor Author

acyza commented Feb 22, 2023

另外给body设置overflow-x:scrolloverflow-x:hidden问题消失也可以间接说明这个top-end比其他的矮一节大概率是滚动条的问题。

@jw-foss
Copy link
Member

jw-foss commented Feb 22, 2023

@acyza good question, 我觉得这个地方是个 bug,应该是我写代码的时候写错了,当时想的是

left: 0;
+++top: 0;
--- right: 0;

Copy link
Member

@jw-foss jw-foss left a comment

Choose a reason for hiding this comment

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

@acyza thank you for fixing this bug, please apply the suggestion so we can get this merged.

packages/hooks/use-popper/index.ts Show resolved Hide resolved
Co-authored-by: Jeremy <15975785+jw-foss@users.noreply.github.com>
@jw-foss jw-foss enabled auto-merge (squash) February 22, 2023 12:23
@jw-foss
Copy link
Member

jw-foss commented Feb 22, 2023

Thank you for your contribution 👍

@jw-foss jw-foss merged commit 1b63470 into element-plus:dev Feb 22, 2023
@acyza acyza deleted the fixTooltip branch February 22, 2023 12:31
@element-bot element-bot mentioned this pull request Mar 3, 2023
3 tasks
loosheng pushed a commit to loosheng/element-plus that referenced this pull request Mar 26, 2023
)

* fix(components): [tooltip] display tooltip correctly

* Update packages/hooks/use-popper/index.ts

Co-authored-by: Jeremy <15975785+jw-foss@users.noreply.github.com>

---------

Co-authored-by: Jeremy <15975785+jw-foss@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Component] [tooltip, popper] Tooltip
2 participants