Skip to content

Commit 3cc566b

Browse files
Fix BrandNavbar burger doesn't show submenus (#2242)
* dropdown click fix click events brad_navbar fix paddinds in submenus fix style in less * remove importans * clean commented code
1 parent 94e4d28 commit 3cc566b

File tree

2 files changed

+22
-32
lines changed

2 files changed

+22
-32
lines changed

geonode_mapstore_client/client/themes/geonode/less/_brand-navbar.less

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@
6666
}
6767
}
6868
}
69+
.dropdown.open .dropdown-menu {
70+
position: static;
71+
box-shadow: none;
72+
border: none;
73+
}
74+
.dropdown {
75+
padding: 3px 10px;
76+
}
6977
}
78+
7079
}
7180
@media (max-width: @screen-sm) {
7281
.gn-brand-navbar-left-menu-container, .gn-search-bar {

geonode_mapstore_client/templates/geonode-mapstore-client/snippets/brand_navbar.html

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -106,44 +106,25 @@
106106
divider.role = "separator";
107107
menuBottomUl.appendChild(divider);
108108
}
109-
109+
110110
// Clone and add all menu items to bottom menu
111111
menuItems.forEach(item => {
112112
const clone = item.cloneNode(true);
113+
113114
if (clone.tagName === 'LI') {
114115
menuBottomUl.appendChild(clone);
115-
} else {
116-
const items = clone.querySelectorAll(':scope > li');
117-
items.forEach(item => {
118-
const dropdownButton = item.querySelector('.dropdown button') || item.querySelector('.dropdown-toggle');
119-
if (dropdownButton) {
120-
// Create a new span with bold text
121-
const buttonText = dropdownButton.textContent.trim();
122-
const boldSpan = document.createElement('span');
123-
boldSpan.className = "dropdown-submenu-title";
124-
boldSpan.textContent = buttonText;
125-
126-
// Add the bold span as a list item
127-
const headerLi = document.createElement('li');
128-
headerLi.appendChild(boldSpan);
129-
appendDivider();
130-
menuBottomUl.appendChild(headerLi);
131-
appendDivider();
132-
133-
// Get all child items from the dropdown menu
134-
const childItems = item.querySelectorAll('.dropdown-menu > li') || item.querySelectorAll('ul > li');
135-
if (childItems) {
136-
childItems.forEach(childItem => {
137-
const _childItem = childItem.cloneNode(true);
138-
_childItem.className = `${_childItem.className} dropdown-submenu`;
139-
menuBottomUl.appendChild(_childItem);
140-
});
116+
117+
const dropdownButton = clone.querySelector('.dropdown button') || clone.querySelector('.dropdown-toggle');
118+
if (dropdownButton) {
119+
dropdownButton.addEventListener('click', function(e) {
120+
e.preventDefault();
121+
e.stopPropagation();
122+
const parentElement = dropdownButton.closest('.dropdown');
123+
if (parentElement) {
124+
parentElement.classList.toggle('open');
141125
}
142-
appendDivider();
143-
} else if (item.tagName === 'LI') {
144-
menuBottomUl.appendChild(item);
145-
}
146-
});
126+
});
127+
}
147128
}
148129
});
149130
}

0 commit comments

Comments
 (0)