When shrinking the window to mobile sizes, the navbar gets a "hamburger icon" which you click to show the main menu. When using Radix with jQuery 1.7 (the Panopoly default) and Bootstrap 3.2.0 (the version Radix pulls from CDN), clicking the "hamburger icon" again fails to hide the main menu. The animation will run but the menu will snap back open.

Using the debugger and walking through the Javascript, I got close to were the problem is:

  • This functionality is provided by the Bootstrap collapse plugin, which has a hide() and show() method
  • Both functions do something like (highly simplified):
    var complete = function () {
      // Make the menu fully hidden or shown.
    };
    $element.width(val).one('bsTransitionEnd', complete);
    
  • The jQuery .one() is meant to ensure that the 'complete' function runs only once, and then is removed as an event handler.
  • What I found in the debugger is that the 'complete' function from both the hide and show is run when clicking to hide the menu!
  • Additionally, for every time I attempted it, it would call the 'complete' function from hide() one additional time. So, it appears that jQuery's .one() function isn't working - the event handlers accumulate

Since I'm testing in a Panopoly context, I haven't tried changing the jQuery version to a newer version. But I did test downgrading Bootstrap from 3.2.0 to 3.1.1. This fixed the problem!

So, I suspect this is some incompatibility between jQuery 1.7 and Bootstrap 3.2.0.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dsnopek’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
609 bytes

Would downgrading the CDN version to 3.1.1 be an option? Looking at the Radix git history, version 3.0.3 was used until November 6th 2014, when it was updated first to 3.3.0 and then down to 3.2.0 when it was discovered that jQuery 1.9 was required for 3.3.0. It would seem that this problem just wasn't noticed! The next closest working version is 3.1.1.

Attached is a patch that does that.

For sites that want a newer version of Bootstrap, they can use the bootstrap_library module and update the jQuery version.

If this isn't an option, is there a way we can make the version of Bootstrap that gets pulled in configurable somehow? We need some way for Radix to work out-of-the-box on Panopoly if we're going to include it.

dsnopek’s picture

Issue tags: +panopoly
klu’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @dsnopek! I'm confirming that Bootstrap 3.2.0 does not work with our Panopoly-based distribution either. Applying the patch to use 3.1.1 solves the issue for me too.

+1 for the suggestion on making the version of Bootstrap that gets pulled in configurable. That would allow maximum flexibility.

PI_Ron’s picture

Thanks for this, all though the patch wouldn't apply for me after downloading the latest dev version. I'm not sure if the dev branch has changed since this patch was created or where I'm going wrong?

I've created a patch that worked for me.

  • arshadcn committed 6a00206 on 7.x-3.x authored by PI_Ron
    Issue #2447319 by dsnopek, PI_Ron: Navbar on mobile won't close with...
shadcn’s picture

Status: Reviewed & tested by the community » Fixed
cmonnow’s picture

I'm wondering which Bootstrap features won't work under jQuery 1.7.1 (and now 3.11 in our case)? I haven't found a feature-specific answer yet. A good number of Drupal 7 contrib modules (and thereby Panopoly) are becoming increasingly ancient.

dsnopek’s picture

I don't know the answer to your question, but you're welcome to help us fix the contrib modules that break with jQuery >1.7! In Panopoly, it's not so much the Panopoly code that breaks, but other contrib modules that we include. We have a number of issues open:

Once all the issues with modules bundled with Panopoly are fixed, it would be possible to increase the jquery version used by Panopoly! But even then, we probably won't increase the default (it'll just be an option), because there's still loads of contrib modules on Drupal.org that will break with jQuery > 1.7.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

cmonnow’s picture

Thanks @dsnopek! I don't actively use any of those modules but it's great to have a list. If I use them or have time I hope to have a look.

I read about so many issues with essential modules such as Views over a year ago that I was afraid to even try (since some jQuery errors could occur in one browser and not another as I found out and this was an unpleasant surprise to deal with).

(As an aside I guess holding back Bootstrap versions could lead to unexpected problems of its own with resolved bugs still in place).