[Tooltip] does not close when being controlled
See original GitHub issue- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
When the tooltip is controlled and the handleClose is shared for the title, if you create a close button and use the handleClose, the tooltip is closed, but after a while it is reopened depends on enterNextDelay
, but it does not close.
Expected Behavior 🤔
The tooltip can be closed normally by the title being controlled.
Steps to Reproduce 🕹
CustomTooltip (to pass handleClose):
import { experimentalStyled, Tooltip, tooltipClasses } from "@material-ui/core";
import React, { useState } from "react";
export default experimentalStyled(
({ className, children, title, ...props }) => {
const [open, setOpen] = useState(false);
const handleOpen = () => {
setOpen(true);
};
const handleClose = () => setOpen(false);
return (
<Tooltip
open={open}
onClose={handleClose}
title={title({ handleClose, isOpen: open })}
children={children({ handleClose, isOpen: open })}
onOpen={handleOpen}
PopperProps={{ keepMounted: true }}
arrow
classes={{ popper: className }}
{...props}
/>
);
}
)(({ theme }) => ({
[`& .${tooltipClasses.tooltip}`]: {
backgroundColor: "#f5f5f9",
color: "rgba(0, 0, 0, 0.87)",
maxWidth: "none",
padding: `${theme.spacing(1.5)} ${theme.spacing(1.5)}`,
boxShadow: theme.shadows[10],
pointerEvents: "auto"
},
[`& .${tooltipClasses.arrow}`]: {
color: "#f5f5f9"
}
}));
App:
<CustomTooltip
title={({ handleClose }) => (
<Box p={5}>
<Button variant="contained" onClick={handleClose}>close</Button>
</Box>
)}>
{({ handleClose }) => (
<Button variant="contained">open tooltip (enter next delay: 0 default)</Button>
)}
</CustomTooltip>
Steps:
- Create a controlled tooltip and pass the handleClose to the title.
- Use this handle close on any button.
- Keep clicking this close button quickly (depends on
enterNextDelay
)
Context 🔦
It seems that there is no lock when the tooltip is closed so as not to open until the animation is finished.
Your Environment 🌎
Google Chrome, but I believe it happens in any browser
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Bootstrap's tooltip doesn't disappear after button click ...
Once the ajax process completed, the button would become "available" again. Hovering on and then off of the button would dismiss the tooltip....
Read more >Tooltip will not close unless users clicks elsewhere on a page.
If you then move your mouse UP (without going over the tooltip) the tooltip will stay open indefinitely until one clicks elsewhere on...
Read more >ARIA: tooltip role - Accessibility - MDN Web Docs - Mozilla
Though a tooltip may appear and disappear, as its appearance is automatic and not intentionally controlled by the user, the aria-expanded ...
Read more >BUG: Dropdown Control tooltip is intermittent
If I change the setting to T:1, B:1, L:5, R:1 the tooltip will display but only if the mouse pointer is placed in...
Read more >ToolTip does not show when they would be over the taskbar ...
Steps to reproduce the behavior: Create a control with ToolTip. Drag Window so that the control is close to the taskbar or dock....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in the next alpha release.
Note that you still need to adjust your component since it has the same problematic CSS we applied:
pointer-events: auto
is no longer necessary in v5. Tooltips are hoverable by default now.Thanks for the report. That is the exact kind of stress tests I was hoping to catch during alpha!
The tooltip can be controlled via
open
prop not thetitle
. Thetitle
shouldn’t depend on the tooltips open state since it’s relevant to the child even if the tooltip isn’t perceivable to grant access to users relying on assistive technology.Tooltips can contain interactive content.
I suspect that the following is happening:
So either we don’t trigger an open while the tooltip is exiting or we disable pointer-events during exit transition.