Side Nav not closing when clicking background


Topic: Side Nav not closing when clicking background

06chaynes pro premium asked 3 months ago

Expected behavior Clicking the background mask when the side nav is open will close the side nav Actual behavior The side nav remains open Resources (screenshots, code snippets etc.)

How can I toggle the side nav closed when the user clicks the background mask? Is there a class


06chaynes pro premium answered 3 months ago

I saw you added an id to the mask, so I was able to add a listener for this:

document.addEventListener("click", function(e) { if (e.target && e.target.id == "sidenav-overlay") { app.toggle = false; } });


Magdalena Dembna staff answered 3 months ago

Hi, Could you provide a code snippet for your case? In our demo application exactly the same behavior of the sidebar and background overlay are presented on the following page: Navigation -> Pro -> SideNav and I'm surprised that clicking the background mask doesn't toggle your side nav by default. Kind regards, Magdalena


Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: Vue
  • MDB Version: 5.1.1
  • Device: MacBook Pro
  • Browser: Chrome 73.0.3683.75
  • OS: macOS 10.14.3
  • Provided sample code: No
  • Provided link: No