-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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] does not close if wrapping icon button with conditional icon #39111
Comments
hello @DenysVuika @zannager , can i pick this task? |
Please provide a CodeSandbox reproducing the issue. The issue template is a good starting point. Code snippets alone are not sufficient, as they don't provide insight into how you're rendering the code. A minimal practical live example is essential. |
Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information. |
Please see the link with example: https://codesandbox.io/s/stoic-wind-zs3hfr?file=/src/App.tsx |
This relates to issues #12246 and #12347. When you move your mouse away, the tooltip will close. However, if you want to close it immediately after clicking, you'll need to customize the behavior with controlled tooltips. See https://codesandbox.io/s/exciting-euler-g2ct58?file=/src/App.tsx. |
👋 Thanks for using MUI Core! We use GitHub issues exclusively as a bug and feature requests tracker, however, For support, please check out https://mui.com/getting-started/support/. Thanks! If you have a question on Stack Overflow, you are welcome to link to it here, it might help others. |
@ZeeshanTamboli the problem is that layout changes, the button moves away, and the tooltip stays there. And the only case when this problem occurs is when icon inside the button is conditionally rendered. Replace that with the static icon and issue won't happen. It's very strange moving to a controlled tooltip and writing more code just to hide the problem. |
Check the second example with a static icon, it works as expected: https://codesandbox.io/s/exciting-pare-gq7q39?file=/src/App.tsx |
@DenysVuika I did some debugging and found that the I believe this issue is related to React issues - facebook/react#6807 and facebook/react#4492. The problem occurs because when elements are conditionally rendered, they get replaced, causing the mouseleave event to be lost. I attempted the solution mentioned in the second point of facebook/react#4492 (comment) by using pointerEvents: none, and it worked. You can check the updated CodeSandbox. I don't see how we can fix this on Material UI's side. |
Duplicates
Latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/stoic-wind-zs3hfr?file=/src/App.tsx
Steps:
The tooltip stays on the screen
The tooltip works as expected
Current behavior 😯
The tooltip stays open on the screen
Expected behavior 🤔
The tooltip should disappear
Context 🔦
I have a button that changes the icon based on the boolean flag. The button is wrapped with the tooltip.
Your environment 🌎
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: