Skip to content

Mobile sidebar does not close when tapping outside of the navbar #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JamesSingleton opened this issue May 3, 2018 · 7 comments · Fixed by coreui/coreui-react#34
Closed

Comments

@JamesSingleton
Copy link

Just an overall question, but I noticed that on Mobile, the sidebar that slides over everything does not close if you tap outside of the sidebar. However, if you tap on the user Avatar and then tap outside of that, it closes. Is there a way to get the sidebar to have the same treatment?

@xidedix
Copy link
Member

xidedix commented May 7, 2018

Hi @JamesSingleton
one of possibilities is document.addEventListener to capture click or touchstart outside Sidebar container.
Any other ideas?

@JamesSingleton
Copy link
Author

@xidedix,

Yea that could work. I don't exactly know how bootstrap does their dropdown/dropdown menu.

Or something like this?

showMenu(event) {
    event.preventDefault();
    
    this.setState({ showMenu: true }, () => {
      document.addEventListener('click', this.closeMenu);
    });
  }
  
  closeMenu() {
    this.setState({ showMenu: false }, () => {
      document.removeEventListener('click', this.closeMenu);
    });
  }

@JamesSingleton
Copy link
Author

@xidedix ,

It looks like I can't assign this to myself but I have made a pull request to address this.

@xidedix
Copy link
Member

xidedix commented Aug 28, 2018

I'm closing this since it appears to be inactive or answered above. Please comment and/or reopen if you feel the issue has not been resolved.

@xidedix xidedix closed this as completed Aug 28, 2018
@carlospauluk
Copy link

Still not working!

@xidedix
Copy link
Member

xidedix commented Apr 8, 2022

@carlospauluk which version?

@carlospauluk
Copy link

@carlospauluk which version?

Sorry, don't know what version I was. But now with 4.1.3 is working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants