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

[Tooltip] Tooltip misaligned when using 100vh and CssBaseline #17774

Closed
2 tasks done
beaudry opened this issue Oct 7, 2019 · 9 comments · Fixed by #17914
Closed
2 tasks done

[Tooltip] Tooltip misaligned when using 100vh and CssBaseline #17774

beaudry opened this issue Oct 7, 2019 · 9 comments · Fixed by #17914
Labels
bug 🐛 Something doesn't work component: Popper The React component. See <Popup> for the latest version. component: tooltip This is the name of the generic UI component, not the React module! external dependency Blocked by external dependency, we can’t do anything about it good first issue Great for first contributions. Enable to learn the contribution process. hacktoberfest https://hacktoberfest.digitalocean.com/

Comments

@beaudry
Copy link
Contributor

beaudry commented Oct 7, 2019

When the #root has a height of 100vh and using the <CssBaseline />, tooltips seem to be misaligned.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

  • When using the <CssBaseline /> alone, the tooltip is centered
  • When using the height: 100vh on the #root alone, the tooltip is centered
  • When using both, the tooltip is not centered, until the window is resized

Expected Behavior 🤔

The Tooltip should be always centered.

Steps to Reproduce 🕹

  1. Go on sandbox
  2. Look on the right
  3. The tooltip is not centered
    4.1. Resize de preview window. It should now be centered. Reload the page
    4.2. Remove the <CssBaseline />. It should now be centered.
    4.3. Add back the <CssBaseline />, then remove the Css import. It should now be centered.

Context 🔦

This appeared when switching from 4.3 to 4.5.

Our situation is not as simple as removing the 100vh. We've opened all our tooltips, and it seems some of them are centered, and some others are not. We are currently trying to investigate on that.

Your Environment 🌎

Tech Version
Material-UI v4.5.0
React 16.10.2
Browser Chromium 79.0.3933.0
@beaudry
Copy link
Contributor Author

beaudry commented Oct 7, 2019

Ok so I've done a few tests, and the bug starts appearing when I update to 4.4.3.

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: tooltip This is the name of the generic UI component, not the React module! external dependency Blocked by external dependency, we can’t do anything about it low priority good first issue Great for first contributions. Enable to learn the contribution process. and removed low priority labels Oct 7, 2019
@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 7, 2019

I confirm, the regression is between 4.4.2 and 4.4.3. It seems that I was too aggressive in my refactoring: 7a86f11. Removing position absolute was the initial motivation, left and top were too good to be true. What do you think of the following diff? Do you want to submit a pull request? :)

diff --git a/packages/material-ui/src/Popper/Popper.js b/packages/material-ui/src/Popper/Popper.js
index 4232a2562..66e3bf9e2 100644
--- a/packages/material-ui/src/Popper/Popper.js
+++ b/packages/material-ui/src/Popper/Popper.js
@@ -212,6 +212,9 @@ const Popper = React.forwardRef(function Popper(props, ref) {
         style={{
           // Prevents scroll issue, waiting for Popper.js to add this style once initiated.
           position: 'fixed',
+          // Fix Popper.js display issue
+          top: 0,
+          left: 0,
         }}
         {...other}
       >

@beaudry
Copy link
Contributor Author

beaudry commented Oct 8, 2019

Sure! I'm on it!

@beaudry
Copy link
Contributor Author

beaudry commented Oct 8, 2019

It works only on the first showing. If you MouseLeave then MouseOver quickly, it moves back to the uncentered place. Just using top: 0 give this result.

From what I could gather, my hypothesis would be linked the scrollbar:

  1. It's rendered below all the html
    1.1. The scrollbar is shown
  2. It calculates the horizontal position
  3. The vertical position is set
    3.1 The tooltip is moved up
    3.2 The scrollbar disappear
  4. Since the scrollbar was on the right, while the position is calculated from the left, and since the content is centered, the horizontal alignment is off.

It would also explain why I needed to have an html node that was height: 100vh to have the bug appear on sandbox.

I'll try to keep digging, but any pointer would be helpful.

@oliviertassinari oliviertassinari removed the good first issue Great for first contributions. Enable to learn the contribution process. label Oct 13, 2019
@oliviertassinari
Copy link
Member

@beaudry I propose to report the issue to Popper.js directly or to consider.

@oliviertassinari oliviertassinari added the component: Popper The React component. See <Popup> for the latest version. label Oct 14, 2019
@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 14, 2019

We had a duplicate report on #17859. I think that we can move the proposed revert forward. It solves a good portion of the issue and has been added in the first place to solve similar issues: #15811.

@rahulkotha18 could you restore the branch so we can reopen your pull request (#17824)? thanks!

@oliviertassinari oliviertassinari added good first issue Great for first contributions. Enable to learn the contribution process. hacktoberfest https://hacktoberfest.digitalocean.com/ labels Oct 15, 2019
@beaudry
Copy link
Contributor Author

beaudry commented Oct 15, 2019

The issue can also be seen on the documentation pages where there is no scrollbar (such as the z-index) when hovering the "Change Language" button.

@beaudry

This comment has been minimized.

@vocko
Copy link

vocko commented Apr 1, 2021

This thing seems to be still broken in 4.11.2.

I'm using drawer for a vertical menu and each menu item has a right side tooltip. When I set 100vh on the root element, all tooltips start to appear on the top of the page instead of next to the menu items as they are supposed to.

Interesting enough, the arrow is still in the correct place.

Any ideas where could be an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: Popper The React component. See <Popup> for the latest version. component: tooltip This is the name of the generic UI component, not the React module! external dependency Blocked by external dependency, we can’t do anything about it good first issue Great for first contributions. Enable to learn the contribution process. hacktoberfest https://hacktoberfest.digitalocean.com/
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants