Navbar: make sure nav buttons with href="#" still get active state.

This fixes a regression from the fix for #5707. That issue was a regression from the fix for #1181. I added the workaround for #1181 again but changed the event to avoid the regression.