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] Tables with ToolTips create extra space on screen #11350

Closed
1 task done
pealmeid opened this issue May 12, 2018 · 6 comments
Closed
1 task done

[ToolTip] Tables with ToolTips create extra space on screen #11350

pealmeid opened this issue May 12, 2018 · 6 comments
Assignees
Labels
bug 🐛 Something doesn't work component: tooltip This is the name of the generic UI component, not the React module!
Milestone

Comments

@pealmeid
Copy link

pealmeid commented May 12, 2018

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Dragging the screen on mobile devices shouldn't move it.

Current Behavior

On screens with tables with tooltips located outside the visible area, the screen moves when you drag it on mobile devices (or Chrome's developer tools screen).

Steps to Reproduce (for bugs)

  1. Open Material-UI's 'Tables' demo (https://material-ui.com/demos/tables/) on Chrome;
  2. Open developer tools (F12);
  3. Toggle device toolbar to simulate mobile device (on dev tools screen);
  4. Drag screen to the left;

Example:

mui-tt-2

For comparison: Same dragging movement on another screen without tables and tooltips:

mui-tt-4

Context

I'm trying to create a sorted table with tooltips and using the demo source as starting point. Noticed this happening and thought it was my mistake until noticing it also happens on the demo page. This only happens if the table has tooltips. If it does not, you cannot drag the screen (as expected).

Your Environment

Tech Version
Material-UI v1.0.0-beta.47
browser Chrome 66.0.3359.139
@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: tooltip This is the name of the generic UI component, not the React module! labels May 12, 2018
@quisido
Copy link
Contributor

quisido commented May 16, 2018

Can verify this. We moved to custom-made tooltips because of this issue. This happens even outside of tables.

I believe this happens on pages with scrollbars, but I may be incorrect. This is due to scrolling. The following is some information that I found useful when creating custom a tooltip component.

This is how I positioned my custom tooltips:

        let offsetTop = 0;
        let offsetParent = this.rootRef;
        while (
          offsetParent !== null &&
          offsetParent !== document.body &&
          offsetParent.nodeName.toLowerCase() !== 'html'
        ) {
          offsetTop += offsetParent.offsetTop;
          offsetTop -= offsetParent.scrollTop;
          offsetParent = offsetParent.offsetParent;
        }

I experienced very similar results to the MUI positioning when I didn't substract offsetParent.scrollTop from the calculated offsetTop for the tooltip.

A horizontal scroll may be caused by a similar issue and need to have all of its parent's scrollLeft subtracted.

Upon further inspection, I do believe this is the case.
The most egregiously positioned tooltip in the OP's link (Table demo) is the "Sort" tooltip that belongs to the Nutrition table (the furthest-right column).

Noticeably, the Nutrition table, when in mobile view, has a horizontal scrollbar, and the tooltips (plural) that are appearing to the right of the screen are positioned where the table would have them if it were not overflowing!

That is to say, tooltips are appearing in locations as if their parents were not overflow:scroll or overflow:hidden.

Either they need to be removed from the DOM until visible, or they need to have their offset adjusted until they are in view of the overflowing parent.

@quisido
Copy link
Contributor

quisido commented May 16, 2018

Sorry, correction to the above algorithms:

        let offsetTop = 0;
        let parentNode = this.rootRef;
        let nextOffsetParent = this.rootRef;
        while (
          parentNode !== null &&
          parentNode !== document.body &&
          parentNode.nodeName.toLowerCase() !== 'html'
        ) {
          offsetTop -= parentNode.scrollTop;
          if (parentNode === nextOffsetParent) {
            offsetTop += parentNode.offsetTop;
            nextOffsetParent = parentNode.offsetParent;
          }
          parentNode = parentNode.parentNode;
        }

You want to subtract the scrollTop of every parent node, but only add the offsetTop of every offsetParents.

I don't know if the current positioning system already does this or not.

It may simply be the case that you just don't want the tooltips to exist in the DOM until they are open.

@DayBr3ak
Copy link

DayBr3ak commented Jun 6, 2018

I've also experienced this issue. A tooltip within a scrollbar is rendered outside of it

@franklixuefei
Copy link
Contributor

This issue #10909 is related. I think we should tackle it.

@plnichols
Copy link

I was still having the same issue, even with the merged Tooltip implementation changes #12085. The solution for me was to add minimum-scale=1 to my meta viewport - like the Material-UI demo site.

<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no">

@oliviertassinari
Copy link
Member

@plnichols https://material-ui.com/getting-started/usage/#responsive-meta-tag ;)

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: tooltip This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

6 participants