Hello everyone 🌟
I've been working on a project using material-UI, and I encountered an issue with the popover functionality. It seems that MUI popovers have a z-index of 1500 which blocks all events like mouseEnter/mouseLeave. I need my users to be able to navigate and interact with buttons and collapse elements within this div, so I decided to try implementing a pure CSS solution instead. After spending hours trying to tweak the behavior of the MUI popover, I ended up grabbing some old CSS from another project. Now, I'm struggling to convert it into a format that MUI accepts.
The CSS code I'm trying to integrate looks like this:
.popover__wrapper {
position: relative;
}
.popover__content {
opacity: 0;
visibility: hidden;
position: absolute;
left: -100px;
transform: translate(0, 10px);
background-color: #bfbfbf;
padding: 1.5rem;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
width: auto;
text-align: center;
}
.popover__content:before {
position: absolute;
z-index: -1;
content: "";
right: calc(50% - 10px);
top: -8px;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #bfbfbf transparent;
transition-duration: 0.3s;
transition-property: transform;
}
.popover__wrapper:hover .popover__content {
z-index: 10;
opacity: 1;
visibility: visible;
transform: translate(0, -20px);
transition: all 0.5s cubic-bezier(0.75, -0.02, 0.2, 0.97);
}
My attempt to adapt this into MUI-compatible CSS is as follows:
popover__content: {
opacity: 0,
visibility: "hidden",
position: "absolute",
left: "-150px",
transform: "translate(0, 10px)",
width: "100%",
"&:before": {
position: "absolute",
zIndex: "-1",
right: "calc(50% - 10px)",
transitionDuration: "0.3s",
transitionProperty: "transform",
},
"&:hover": {
zIndex: "10",
opacity: "1",
visibility: "visible",
transform: "translate(0, -20px)",
transition: " all 0.5s cubic-bezier(0.75, -0.02, 0.2, 0.97)",
},
},
I've consulted the MUI theming documentation, but I'm still stuck on this issue. Any help or guidance would be greatly appreciated! Have a fantastic day, everyone!