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.
The Tooltip having a z-Index above the one of the MenuItem (although this may be specific to my very own use case only)
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.
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.
The tooltip stays displayed on top of everything until the Select component is hovered, or the user clicks anywhere other than the Select component.
Here is the live example on codesandbox.io.
| Tech | Version |
|--------------|---------|
| Material-UI | next |
| React | 16.0.0 |
| browser | Chrome 65.0.3325.181 |
@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.
Most helpful comment
I found a fix for my issue. See here.