I need to resolve issue of responsive megamenu for mobile.
The issue is when I click on the subcategory to opens its child sub-categories the link gets clicked and gets redirected because of which seeing expanded menu gets difficult.
However I tried to locate the code due to which this happens. Below is the code which is present in menu.js file:
_toggleMobileMode: function () {
$(this.element).off('mouseenter mouseleave');
this._on({
"click .ui-menu-item:has(a)": function (event) {
event.preventDefault();
var target = $(event.target).closest(".ui-menu-item");
if (!target.hasClass('level-top') || !target.has(".ui-menu").length) {
window.location.href = target.find('> a').attr('href');
}
},
"click .ui-menu-item:has(.ui-state-active)": function (event) {
this.collapseAll(event, true);
}
});
var subMenus = this.element.find('.level-top');
$.each(subMenus, $.proxy(function (index, item) {
var category = $(item).find('> a span').not('.ui-menu-icon').text(),
categoryUrl = $(item).find('> a').attr('href'),
menu = $(item).find('> .ui-menu');
this.categoryLink = $('<a>')
.attr('href', categoryUrl)
.text($.mage.__('All ') + category);
this.categoryParent = $('<li>')
.addClass('ui-menu-item all-category')
.html(this.categoryLink);
if (menu.find('.all-category').length === 0) {
menu.prepend(this.categoryParent);
}
}, this));
}
What I need is that when we click on pseudo element(which shows expansion and contraction) of the sub-category, its child sub-categories should be shown and clicking on sub-category anyways redirects to that particular sub-category page.
Can someone please help me.