I am trying to create a React Material Popover(https://material-ui.com/api/popover/) element, to be shown when user hovers mouse over a TableRow (https://material-ui.com/api/table-row/), and to be hidden when user hovers mouse out of the TableRow.
What I have already tried :
const handlePopoverOpen = event => {
setAnchorEl(event.currentTarget);
};
const handlePopoverClose = event => {
setAnchorEl(null);
};
const open = Boolean(anchorEl);
. . .
<TableRow
selected={props.selected === key ? true : false}
hover={true}
key={key} className={classes.tableBodyRow}
onClick={() => props.onSelectChange(key, prop[0], prop[1])}
onMouseOver={handlePopoverOpen}
onMouseOut={handlePopoverClose}
>
. . .
<Popover
id="mouse-over-popover"
open={open}
anchorEl={anchorEl}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'center',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'left',
}}
onClose={handlePopoverClose}
>
I use Popover
</Popover>
Popover appears when mouse is hovered over the TableRow, but then it keeps blinking like there is an infinite loop of onMouseOver() and onMouseOut(). I have been investigating this issue for hours and I cant find the explanation of this issue. I would appreciate if someone could help!
Here is a code live demo: https://codesandbox.io/s/heuristic-banach-071f3?fontsize=14&hidenavigation=1&theme=dark