Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

194
Views
cómo detener la ocultación de la barra lateral después de seleccionar elementos de navegación secundaria

Quiero ocultar la barra lateral después de seleccionar elementos o hacer clic fuera de la página. Escribí este código, funcionó, pero el principal problema es que oculta la barra lateral cuando hago clic en los elementos que tienen subnav que se oculta y hago clic en el botón de menú nuevamente, luego selecciono los elementos en subnav. Porfavor ayudame a resolver este problema.

 enter code here const Nav = styled.div` background: #15171c; height: 80px; width: 7%; display: flex; justify-content: flex-start; align-items: center; position:fixed; z-index:998; `; const NavIcon = styled(Link)` margin-left: 2rem; font-size: 2rem; height: 80px; display: flex; justify-content: flex-start; align-items: center; `; const SidebarNav = styled.nav` width: 100%; height: 100%; display: flex; justify-content: center; position: fixed; z-index:999; top: 0; left: ${({ sidebar }) => (sidebar ? "0" : "-100%")}; transition: 350ms; clip-path: polygon(0 0, 38% 0, 18% 100%, 0% 100%); background-color: #c10273; overflow-y:scroll; `; const SidebarWrap = styled.div` width: 100%; `; const Sidebar = () => { let useClickOutside = (handler) => { let domNode = useRef(); useEffect(() => { let maybeHandler = (event) => { if (!domNode.current.contains(event.target)) { handler(); } }; document.addEventListener("mousedown", maybeHandler); return () => { document.removeEventListener("mousedown", maybeHandler); }; }); return domNode; }; const [sidebar, setSidebar] = useState(false); const showSidebar = () => setSidebar(!sidebar); let domNode = useClickOutside(() => { setSidebar(false); }); return ( <> <IconContext.Provider value={{ color: "#fff" }}> <Nav ref={domNode}> <NavIcon to="#"> <FaIcons.FaBars onClick={showSidebar} value={{color:"#c10273"}} /> </NavIcon> </Nav> <SidebarNav sidebar={sidebar}> <SidebarWrap> <NavIcon to="#"> <AiIcons.AiOutlineClose onClick={showSidebar} /> </NavIcon> {SidebarData.map((item, index) => { return <Subnav item={item} key={index} />; })} </SidebarWrap> </SidebarNav> </IconContext.Provider> </> ); }; export default Sidebar;

Por favor, ayúdame

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!