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
Add a ment  | 

2 Answers 2

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>
  );
}

本文标签: