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

210
Views
React sidebar dropdown menu is overlapping with options

I am working on this sidebar for a project. I am facing a problem.
Required Behavior If I click on an option which has a submenu, it will show the submenu below the clicked option. And it will push down the other options below. e.g this sidebar https://med.stanford.edu/ultrasound/research.html
Current Behavior
If I click on an option, it overlaps the below options. How to fix this?

My sidebar Component

import { useState } from "react";
import { Box, Text } from "@chakra-ui/react";
import sidebarItems from "./sidebarItems";


export default function Sidebar() {
  const [selectedSubMenu, setSelectedSubMenu] = useState("");
  const [isOpen, setIsOpen] = useState(false);
  const handleClick = (title) => {
    setSelectedSubMenu(title);
    setIsOpen(!isOpen);
  };

  return (
    <div>
      <Box>
        {sidebarItems.map((items) => {
          return (
            <Box
              width='200px'
              height='40px'
              textAlign='start'
              cursor='pointer'
              onClick={() => handleClick(items.title)}
              fontFamily='Fjord One'
              boxShadow='lg'
              _hover={{
                bgColor: "#1a2963",
                color: "white",
              }}
            >
              <Text fontSize='xl' as='bold'>
                {items.title}
              </Text>
              {isOpen && items.title === selectedSubMenu
                ? items.subMenu?.map((item) => {
                    return (
                      <Box
                        bgColor='#e4e8e5'
                        boxShadow='md'
                        textAlign='start'
                        width='200px'
                        height='40px'
                      >
                        <Text fontFamily='Fjord One' fontSize='xl'>
                          {item.title}{" "}
                        </Text>
                      </Box>
                    );
                  })
                : null}
            </Box>
          );
        })}
      </Box>
    </div>
  );
}
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!