admin管理员组文章数量:1335138
Here is how my custom Modal ponent is defined:
function Modal({ open, set_open, children }) {
const modal_ref = useRef(null);
useEffect(() => {
if (open) {
modal_ref.current.style.display = "block";
} else {
modal_ref.current.style.display = "none";
}
}, [open]);
return ReactDom.createPortal(
<div className="modal-container" ref={modal_ref}>
<div className="modal-content">{children}</div>
</div>,
document.getElementById("root")
);
}
The children property of the ponent will contain the tooltip. Or it may actually be the grandchildren.
But either way, it should appear, no?
Here is how my custom Modal ponent is defined:
function Modal({ open, set_open, children }) {
const modal_ref = useRef(null);
useEffect(() => {
if (open) {
modal_ref.current.style.display = "block";
} else {
modal_ref.current.style.display = "none";
}
}, [open]);
return ReactDom.createPortal(
<div className="modal-container" ref={modal_ref}>
<div className="modal-content">{children}</div>
</div>,
document.getElementById("root")
);
}
The children property of the ponent will contain the tooltip. Or it may actually be the grandchildren.
But either way, it should appear, no?
Share Improve this question asked Jul 31, 2021 at 14:05 Bear Bile Farming is TortureBear Bile Farming is Torture 5,1618 gold badges41 silver badges118 bronze badges 3- It can be a z-index problem. please increase the z-index of the tooltip larger than the modal – TopW3 Commented Jul 31, 2021 at 14:37
- I tried that. I applied the highest zIndex to the style property of the Tooltip. Didn't work – Bear Bile Farming is Torture Commented Jul 31, 2021 at 19:41
- Please provide a code sandbox reproducing your problem. – Ryan Cogswell Commented Aug 1, 2021 at 3:40
2 Answers
Reset to default 7.MuiTooltip-popper {
z-index: 9999999 !important;
}
As much as I hate using !important
, that's what did the trick for me.
You can set this via a mui theme override as well.
export default function ThemeProvider({ children }: Props) {
const theme = createTheme({
zIndex: { tooltip: 99999 },
});
return (
<MUIThemeProvider theme={theme}>
{children}
</MUIThemeProvider>
);
}
本文标签:
版权声明:本文标题:javascript - Material UI Tooltip does not appear when rendered inside of a custom Modal component - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742267475a2443680.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论