JS Error in we_mobile_menu.js: Cannot read property 'removeClass' of undefined

Created on 17 September 2021, about 3 years ago
Updated 3 October 2023, about 1 year ago

Problem/Motivation

There is a Javascript error popping up when I resize the browser window.

we_mobile_menu.js?v=1:30
Uncaught TypeError: Cannot read property 'removeClass' of undefined
    at we_mobile_menu.js?v=1:30
    at dispatch (jquery.min.js?v=3.6.0:2)
    at v.handle (jquery.min.js?v=3.6.0:2)

Looking at the code in question, there is (jQuery) object called item which does not seem to be defined under all circumstances. In particular it will only be defined if the option accordionMenu is set to "true".

The default value of that option is in fact "true", but we had to use the jQuery function mobileMenu() (which this is about) in another context in which we set that option to false. I would say that this option should be supported to be false. Otherwise why have it in the first place, right? I hope I did not misunderstand anything.

Steps to reproduce

Use the jQuery function mobileMenu() with the option accordionMenu set to false. Then view the page and resize the browser window.

Proposed resolution

The object item should only be manipulated on window resize if it is defined.

🐛 Bug report
Status

Needs review

Version

1.16

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024