-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
[SpeedDial] Tooltip not closing when quickly moving the mouse away #25215
Comments
This is a regression from v5. I can't reproduce on v4. Looking at this, I have found two other things that are not flying:
|
@oliviertassinari In my investigation, I found that wrapping diff --git a/packages/material-ui/src/SpeedDial/SpeedDial.js b/packages/material-ui/src/SpeedDial/SpeedDial.js
index 3daec5a653..ac2fd684d7 100644
--- a/packages/material-ui/src/SpeedDial/SpeedDial.js
+++ b/packages/material-ui/src/SpeedDial/SpeedDial.js
@@ -274,20 +274,13 @@ const SpeedDial = React.forwardRef(function SpeedDial(inProps, ref) {
}
clearTimeout(eventTimer.current);
- if (event.type === 'blur') {
- event.persist();
- eventTimer.current = setTimeout(() => {
- setOpenState(false);
- if (onClose) {
- onClose(event, 'blur');
- }
- });
- } else {
+ event.persist();
+ eventTimer.current = setTimeout(() => {
setOpenState(false);
if (onClose) {
- onClose(event, 'mouseLeave');
+ onClose(event, event.type === 'mouseleave' ? 'mouseLeave' : 'blur');
}
- }
+ });
};
const handleClick = (event) => { |
@m4theushw Have done a new quick exploration (~10 minutes), I can up with an alternative solution: diff --git a/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js b/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js
index 8557d632ce..8e9a8c191b 100644
--- a/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js
+++ b/packages/material-ui/src/SpeedDialAction/SpeedDialAction.js
@@ -151,6 +151,10 @@ const SpeedDialAction = React.forwardRef(function SpeedDialAction(inProps, ref)
const [tooltipOpen, setTooltipOpen] = React.useState(tooltipOpenProp);
+ if (!open && tooltipOpen) {
+ setTooltipOpen(false);
+ }
+
const handleTooltipClose = () => {
setTooltipOpen(false);
}; It seems that a reset of the tooltip state to close when the speed dial is closed is a sane default. I have noticed this because the tooltip onClose callback tries to trigger but the open prop of the Tooltip is already set to false once it triggers. Also, note that I could easily reproduce the error: Maybe it will help you with the test case. IMHO, we should favor a solution that isn't depending on the order of setTimeout resolution (it would be more resilient to future changes). |
Current Behavior 😯
If I quickly move the mouse away from the speed dial while a tooltip is open, when I open it again that previous tooltip will still be visible. Interacting via keyboard also causes this behavior.
Expected Behavior 🤔
The tooltip should not be already visible on the second time that the speed dial is open.
Steps to Reproduce 🕹
https://codesandbox.io/s/1ssec?file=/demo.tsx
Steps:
Context 🔦
I noticed while doing #25166. It was also happening with the non-emotion component.
PR on the way.Your Environment 🌎
`npx @material-ui/envinfo`
The text was updated successfully, but these errors were encountered: