From fbd437da39f1e1fd951965e13b7efdc41ce7e7f0 Mon Sep 17 00:00:00 2001 From: Vinicius Bueno Date: Mon, 3 Jun 2024 09:45:26 -0300 Subject: [PATCH] fixed mobile menu close after click at nav link --- Frontend/src/components/Header.jsx | 14 +++++++----- Frontend/src/components/Nav.jsx | 34 +++++++++++++++++++----------- Frontend/src/components/Search.jsx | 3 ++- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/Frontend/src/components/Header.jsx b/Frontend/src/components/Header.jsx index 0b45cf4..823c04c 100644 --- a/Frontend/src/components/Header.jsx +++ b/Frontend/src/components/Header.jsx @@ -57,7 +57,7 @@ function Header() { }; const toggleCart = () => { - console.log(calculateTotalItems(cartItems)) + console.log(calculateTotalItems(cartItems)); setIsCartOpen((prevState) => !prevState); }; @@ -91,13 +91,17 @@ function Header() { {!isLoginPage && !isRegisterPage && isLoggedIn && ( <> {' '} -
  • - +
  • - +
  • - +
  • diff --git a/Frontend/src/components/Search.jsx b/Frontend/src/components/Search.jsx index d53fa2c..9e55561 100644 --- a/Frontend/src/components/Search.jsx +++ b/Frontend/src/components/Search.jsx @@ -2,7 +2,7 @@ import './Search.css'; import { useState } from 'react'; import { useNavigate, useLocation, useSearchParams } from 'react-router-dom'; -function Search({ menuOpen }) { +function Search({ menuOpen, setMenuOpen }) { const [searchParams, setSearchParams] = useSearchParams({ q: '' }); const navigate = useNavigate(); const [searchFile, setSearchFile] = useState(''); @@ -17,6 +17,7 @@ function Search({ menuOpen }) { setSearchParams('q', searchFile); navigate(`/store?q=${searchFile}`); setSearchFile(''); + setMenuOpen(false); }; return (