Tooltip should disappear after dialog opening.
Tooltip stay open and nothing can close it, except mouseleave event on the wrapped element.
https://codesandbox.io/s/18z30978jj
| Tech | Version |
|--------------|---------|
| Material-UI | 3.0.3 |
| React | 16.5.0 |
It is because when the modal closes, it restores focus on the last element, in this case the tooltip'd button.
To disable this you have (at least) two options:
disableRestoreFocus prop to the Modal component.disableFocusListener prop to the Tooltip component.@ayubov Thank you for providing this reproduction example. It took some time to look into it. I can confirm the bug. A onFocus event is triggered but no onBlur event is triggered. There is a simple workaround. We can check that we still have the active focus here:
https://github.com/mui-org/material-ui/blob/851e847764ea3a7640c7aca7b8a72f089521d0f3/packages/material-ui/src/Tooltip/Tooltip.js#L136-L143
Something like:
handleFocus = event => {
event.persist();
// The autoFocus of React might trigger the event before the componentDidMount.
// We need to account for this eventuality.
this.focusTimer = setTimeout(() => {
- this.handleEnter(event);
+ if (this.childrenRef === document.activeElement) {
+ this.handleEnter(event);
+ }
});
};
@ayubov Do you want to give it a shot?
@oliviertassinari Yes, I'll try.
@oliviertassinari Can you please help me little bit? It’s my first time with yarn, maybe I misunderstood something. After I cloned repository and installed dependencies with ‘yarn install’ I’m trying to build it with ‘yarn build’ and getting Syntax error on the first spread operator in the first file AppBar. Looks like Babel plugin doesn’t work, or something like this. What is my mistake?
@ayubov try yarn instead to install packages
@shcherbyakdev it's not the reason. yarn install works exactly the same as yarn.
@ayubov Do you have the same issue as #12886? If so please continue the conversation over there by stating your OS and shell you used.
@oliviertassinari Your solution works perfect, I created PR with it.
still have problem if modal opens via react-router
https://codesandbox.io/s/ox9ro67yk6
and it looks more critical since it is jumping to other place and break up layout.
@mogadanez Interesting. Thank you for making this codesandbox! I have made #12953 recently to improve this case. Looks like it's not enough. I also want to add a warning to the console when this happens. Would you mind opening a new issue? I will share the workaround there.