Topic: Mobile navbar stays collapsed although toggle state changes

samCodes free asked 2 weeks ago


The hamburger click updates our state and logs the new value. Below the desktop breakpoint, the navigation links remain invisible.

Which prop controls MDBCollapse visibility?


Mateusz Lazaru staff answered 2 weeks ago


Pass your visibility state to MDBCollapse through open, for example <MDBCollapse navbar open={showNav}>. If you currently pass show, replace it with open while keeping the same state variable connected to the hamburger handler and the collapse component.

If the links are still invisible after that change, send the complete navbar JSX and stylesheet imports. Please also inspect whether the collapse element becomes visible when open is true, and include any custom display, height, or overflow rules affecting the navigation container.

https://mdbootstrap.com/docs/react/navigation/navbar/


samCodes free commented 2 weeks ago

That was it: the handler updated showNav, but the collapse still received show. Changing that prop to open fixed the mobile menu. It now opens and closes correctly, and our separate close button works with the same state too.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: MDB5 9.0.0
  • Device: Desktop
  • Browser: Chrome
  • OS: Windows 11
  • Provided sample code: No
  • Provided link: No