Skip to content

Commit f0d9998

Browse files
committed
fix: bug with overlay in mobile navbar
1 parent 6d784e4 commit f0d9998

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

web/src/layout/Header/MobileHeader.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React, { useState } from "react";
22
import styled, { css } from "styled-components";
33
import HamburgerIcon from "svgs/header/hamburger.svg";
44

5+
import { useLockBodyScroll } from "react-use";
6+
57
import { landscapeStyle } from "styles/landscapeStyle";
68

79
import LightButton from "components/LightButton";
@@ -34,17 +36,18 @@ const StyledLightButton = styled(LightButton)`
3436
}
3537
`;
3638

37-
const Overlay = styled.div<{ isOpen: boolean }>`
38-
display: ${({ isOpen }) => (isOpen ? "block" : "none")};
39-
position: absolute;
39+
const Overlay = styled.div`
40+
position: fixed;
4041
top: 0;
41-
width: 100vw;
42+
left: 0;
43+
width: 100%;
4244
height: 64px;
4345
z-index: 1;
4446
`;
4547

4648
const MobileHeader = () => {
4749
const [isOpen, setIsOpen] = useState(false);
50+
useLockBodyScroll(isOpen);
4851

4952
const handleOpenNavbar = () => {
5053
setIsOpen(true);
@@ -57,7 +60,6 @@ const MobileHeader = () => {
5760
return (
5861
<Container>
5962
{isOpen ? <Overlay {...{ isOpen }} onClick={handleCloseNavbar} /> : null}
60-
6163
<Logo />
6264
<StyledLightButton text="" Icon={HamburgerIcon} onClick={handleOpenNavbar} />
6365
<NavBar {...{ isOpen, handleCloseNavbar }} />

0 commit comments

Comments
 (0)