Skip to content
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

Close opened navbar content on window resize #11653

Closed
mdo opened this issue Nov 30, 2013 · 5 comments
Closed

Close opened navbar content on window resize #11653

mdo opened this issue Nov 30, 2013 · 5 comments

Comments

@mdo
Copy link
Member

mdo commented Nov 30, 2013

Currently this is duped a few times over: #11243, #11301, and #11382—but the issue is described differently everywhere. This should clear things up and help us figure out what to do to fix it.

Problem

Starting with a narrow viewport, one with the collapsed navbar contents, open the menu, then resize to full-width with all navbar contents visible. Shrinking the viewport back to the narrow size still shows the un-collapsed navbar contents.

(Btw, this is currently visible in the docs.)

Why this happens

We're using the collapse plugin to do this. Right now it has no idea about the dimensions of your viewport. All it does is toggle the appropriate classes based on clicks—click to open, click to hide.

Our CSS utilizes those changes in classes from the plugin to style the menu accordingly. The CSS has no way to remove the .in class that the JS adds.

Fix

We need the JS plugin to be updated to detect the viewport changes and remove the class. I don't know when or how this could happen, but that's the only solution. Will need to hear from @fat or anyone else with more JS-fu.

@fat
Copy link
Member

fat commented Dec 24, 2013

hm… well our nav is just using our default collapse plugin… which shouldn't be aware of viewport changes. Because this is a pretty specific nav related case.

Also, there's no bug in our docs afaik… there's only a bug/unexpected bahior if you have a dropdown in your navbar?

At any rate… the js is super easy bb:

$(window).on('resize', function () {
  if (window.innerWidth > tabletSize) $('.bs-navbar-collapse').collapse('hide')
})

@fat
Copy link
Member

fat commented Dec 25, 2013

if people have that bug, i'd recommend just adding that snippet… we could add it to the bottom of the the collapse plugin but it's kinda gross. your call tho, let me know if you'd like me to add it.

@mdo
Copy link
Member Author

mdo commented Jan 11, 2014

Nah, punting on this for now.

@NazarenoL
Copy link

I lost at least one hour trying to decipher why my header breaks after shrinking, opening the menu and then enlarging. I'm now using the @fat script line, and it fixed it.

I don't think that this should be included with the collapse plugin, but with the bootstrap js that applies collapse to the menus.

@sschenk
Copy link

sschenk commented Feb 20, 2018

Why is this closed what's the solution for v3.6?

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

No branches or pull requests

4 participants