Material-ui: Tooltip stays displayed on top of MenuItem components of a Select component

Created on 30 Apr 2018  路  6Comments  路  Source: mui-org/material-ui

When using a Tooltip component around a Select component containing MenuItems, when you click the Select (not only Tooltip stays displayed but it also sticks above the MenuItems) and click a MenuItem, the Tooltip stays displayed as if we were still hovering the Select component. Now to make it disappear you can re-hover the Select, or click anywhere else in the DOM.

I feel like these are two separate issues.

  1. The Tooltip having a z-Index above the one of the MenuItem (although this may be specific to my very own use case only)

  2. The other one would be that the tooltip stays displayed after clicking a MenuItem to change the Select's value, when it is not even being hovered anymore.

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

Expected Behavior


When clicking the Select component, the tooltip should disappear. Therefore, when the MenuItems appear, they won't have the tooltip on top of them, and if your MenuItems have a tooltip, it will still be displayed above the other MenuItems as you would expect it and the tooltip would still be invisible after selecting an item in the Select component.

Current Behavior


The tooltip stays displayed on top of everything until the Select component is hovered, or the user clicks anywhere other than the Select component.

Steps to Reproduce (for bugs)


Here is the live example on codesandbox.io.

  1. Click the Select component. (Notice the tooltip stays on top of the MenuItems)
  2. Select any of the MenuItems. (Notice how the Tooltip flickers as you move your mouse)
  3. Click it (The MenuItems disappear but the tooltip is still displayed as if there was a mouse hovering the Select)

Context

Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | next |
| React | 16.0.0 |
| browser | Chrome 65.0.3325.181 |

bug 馃悰 Tooltip

Most helpful comment

I found a fix for my issue. See here.

All 6 comments

@oliviertassinari I would like to know if this actually an issue or not, if possible! I know that a Button with a Menu/MenuItems has the behavior that I want but I am limited to the use of Select in my case.

I'm experiencing the same issue. I have a tooltip on an icon button that opens a dialog. After the dialog is dismissed, the tooltip appears and will remain active until the button is activated with a mouseover event.

I found a fix for my issue. See here.

I think there are two separate issues here.

The first issue (@Tuaniwan's example) occurs when using a Tooltip around a component that creates a modal, ie a Select or Menu. The onMouseLeave event doesn't fire on the Select as you would expect when the modal opens on top of it. I think this is due to the way that event bubbling works in portals. Even though the Menu is rendered outside of the Select in the DOM, onMouseEnter and onMouseLeave behave as though its a child.

There is an open issue about this on the React repo facebook/react#11387.

I got my asnwer here.

The controlled answer looks good to me: https://codesandbox.io/s/oxlmqo4m9z.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryanflorence picture ryanflorence  路  3Comments

finaiized picture finaiized  路  3Comments

ghost picture ghost  路  3Comments

pola88 picture pola88  路  3Comments

ericraffin picture ericraffin  路  3Comments