Problem/Motivation

Upgraded to rc3 and received JS errors breaking admin menu.

Steps to reproduce

TB Megamenu block added to admin region in custom theme.

No .tb-megamenu present to set navParent in tb_megamenu-frontend.js:57
var navParent = document.querySelector('.tb-megamenu')

Proposed resolution

Check for navParent == null when adding events in tb_megamenu-frontend.js:96

      /* Event Listener */
      // On Keydown
      navParent.addEventListener('keydown',keydownEvent)

to

      /* Event Listener */
      if ( navParent !== null ) {
        // On Keydown
        navParent.addEventListener('keydown',keydownEvent);
      }

Comments

ponies created an issue. See original summary.

knaffles’s picture

I'm going to create a patch that should fix this regardless, but I'm a little confused because the front end JS should only ever be added if a TB MegaMenu block is present. How exactly are you including a TB MegaMenu block in an admin region? Is it safe to say that the error shows up when a non-admin views a page?

ponies’s picture

The menu block was configured to be included in a sidebar region of a custom admin theme, and navigation region of the public theme. The sidebar rendered empty with 0 width. I'm not sure how long the menu block had been there, but it only started throwing errors after the rc3 update. Removing the block from the admin pages fixed the error. I haven't dug into it but I suspect that how the admin theme is handling it's regions is broken somehow.

If navParent's ever null it's probably an error with something upstream. Maybe log an error there?

rbrownell’s picture

Status: Active » Closed (outdated)

Thanks for the report and for contributing to the TB Mega Menu issue queue.

Drupal 7 reached end of life on January 5, 2025 and is no longer supported going forward.

As part of wrapping up Drupal 7 support for this project, issues that do not include a code-based resolution (including issues where the only patch is out of date and requires a re-roll) are being closed as Outdated as part of this cleanup.

This closure reflects the end-of-life status of Drupal 7 and the absence of an up-to-date fix we can act on, not the validity of the issue itself.

If the issue applies to a currently supported version of Drupal, please open a new issue with updated details.

Thanks again to everyone who contributed during Drupal 7’s lifecycle.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.