Fix a bug in the navbar collapse code

The old code caused the navbar to be shown if the user clicks the brand
logo, and then makes the window small enough that the navbar gets collapsed.