Skip to content

Commit

Permalink
fix(themodal.jsx): use createPortal to ensure modal is always top
Browse files Browse the repository at this point in the history
fixes #20
  • Loading branch information
junglesub committed Aug 5, 2024
1 parent ae5266b commit c8c6b22
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ function Header({ loggedIn = false, ...props }) {
</HeaderMenus>
</HeaderCompContent>

<TheModal openModal={openModal} setOpenModal={setOpenModal}>
<TheModal
openModal={openModal}
setOpenModal={setOpenModal}
style={{
color: "white",
}}
>
<HeaderModalLoginText.logo>
<img src={headerLogo} />
</HeaderModalLoginText.logo>
Expand Down
6 changes: 4 additions & 2 deletions src/components/TheModal.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useEffect, useRef, useState } from "react";
import ReactDOM from "react-dom";
import styled from "styled-components";

function TheModal({
Expand All @@ -8,7 +9,7 @@ function TheModal({
style,
backdropStyle,
}) {
return (
return ReactDOM.createPortal(
<HeaderModal className={openModal}>
<HeaderModalBackdrop
className={openModal}
Expand All @@ -18,7 +19,8 @@ function TheModal({
<HeaderModalContent className={openModal} style={style}>
{ModalContent}
</HeaderModalContent>
</HeaderModal>
</HeaderModal>,
document.body
);
}

Expand Down

0 comments on commit c8c6b22

Please sign in to comment.