themesberg / themesberg/flowbite-react

Multiple MegaMenuDropdowns: Positioning and functionality issues with centered layout

Open
#1,610 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

confirmed
Dominant language
TypeScript
Stars
2.1k
Forks
506
PR merge metrics
No merged PRs in 30d

Description

  • I have searched the Issues to see if this bug has already been reported
  • I have tested the latest version

We need to implement a navbar with multiple mega menu dropdowns that have consistent width and centered positioning, as shown in the attached image. However, we're encountering two main issues when trying to achieve this with flowbite-react components and Flotiq React Blocks PRO examples.

Image

Issues Encountered

Issue 1: MegaMenuDropdownToggle Approach

When using MegaMenuDropdownToggle components (from FlowbiteBlock PRO MegaMenuHeader example):

  • Only the first dropdown opens correctly
  • All subsequent dropdowns open the same (first) dropdown content
  • Setting custom id attributes and data-collapse-toggle properties doesn't resolve the issue
  • The menuOpen prop doesn't work as expected (menu opens by default regardless of the prop value)
Issue 2: MegaMenuDropdown with toggle Prop Approach

When using MegaMenuDropdown components with the toggle prop:

  • Multiple dropdowns work functionally (each opens its own content)
  • However, it's impossible to achieve consistent centered positioning
  • CSS positioning attempts fail:
    • theme.base with fixed, left-1/2, and -translate-x-1/2 classes don't center properly
    • Inline style prop with left: "50%" and transform: "translateX(-50%)" gets overridden
    • Custom theme styles are ignored or overridden by internal component styles
Issue 3: Multiple MegaMenu Components

When trying to use multiple MegaMenu components within a single NavbarCollapse:

  • Clicking one dropdown doesn't close others (multiple dropdowns can be open simultaneously)
  • Creates invalid HTML structure (nested <nav> elements within <ul>)

Steps to reproduce

Reproduce Issue 1 (MegaMenuDropdownToggle)
  1. Visit the CodeSandbox example
  2. Ensure preview is at least 1280px width (desktop view)
  3. Click "Company" in the first navbar
  4. Click "Marketing" in the first navbar
Current behavior

Both buttons open the same dropdown content.

Expected behavior

Each button should open its own unique dropdown content, with proper toggle behavior (clicking one closes the other).

Reproduce Issue 2 (MegaMenuDropdown styling)
  1. Visit the same CodeSandbox example
  2. Ensure preview is at least 1280px width (desktop view)
  3. Click "Company" in the second navbar
  4. Click "Marketing" in the second navbar
  5. Observe the positioning of the dropdown menus
Current behavior

Dropdowns open but are not centered consistently. Styling attempts are ignored.

Expected behavior

All dropdowns should be centered horizontally on the page with consistent positioning, similar to the first navbar's visual appearance.

Context

This issue occurs across all browsers, screen sizes, and operating systems.

Demo Repository: https://codesandbox.io/p/github/SalvadorDalia/flowbite-mega-menu/main

Expected Solution

We need a way to:

  1. Create multiple functional mega menu dropdowns within a single navbar
  2. Ensure each dropdown opens its own unique content
  3. Provide reliable styling options for consistent centered positioning
  4. Maintain proper HTML semantics and accessibility
  5. Support proper toggle behavior (opening one closes others)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with MegaMenuDropdownToggle, MegaMenuDropdown, and NavbarCollapse using the linked CodeSandbox reproductions at desktop width. Trace how each dropdown is identified, positioned, and composed in the navbar, including the nested nav structure. Done means distinct dropdown content toggles correctly, one closes when another opens, menus are consistently centered, and the resulting HTML remains accessible and valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, tailwindcss, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.