Skip to content

Commit 59cf998

Browse files
authored
Merge pull request #646 from tblivet/issue-637
2 parents 063b4dc + 77780e9 commit 59cf998

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

modules/ps_mainmenu/ps_mainmenu.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
>
88
{foreach from=$nodes item=node}
99
<li
10-
class="{$node.type}{if $node.current} current{/if}{if $depth === 0} main-menu__tree__item d-flex align-items-center h-100{/if}"
10+
class="{$node.type}{if $node.current} current{/if}{if $depth === 0} js-menu-item-lvl-0 main-menu__tree__item d-flex align-items-center h-100{/if}"
1111
id="{$node.page_identifier}"
1212
>
1313
{if $depth > 1 && $node.children|count}
@@ -105,7 +105,7 @@
105105
{/function}
106106

107107
<div class="main-menu col-xl col-auto d-flex align-items-center">
108-
<div class="d-none d-xl-block position-static js-menu-desktop h-100">
108+
<div class="d-none d-xl-block position-static js-menu-desktop">
109109
{desktopMenu nodes=$menu.children}
110110
</div>
111111

src/js/constants/selectors-map.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ export const visiblePassword = {
117117
export const desktopMenu = {
118118
dropdownToggles: '.js-menu-desktop .dropdown .dropdown-toggle[data-depth]',
119119
dropdownItemAnchor: (depth: number) => `.js-menu-desktop a[data-depth="${depth}"]`,
120+
menuItemsLvl0: '.js-menu-item-lvl-0',
121+
subMenu: '.js-sub-menu',
120122
};
121123

122124
export const qtyInput = {

src/js/modules/ps_mainmenu.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ const initDesktopMenu = () => {
1515
const {Theme} = window;
1616
const {desktopMenu: desktopMenuMap} = Theme.selectors;
1717

18+
/**
19+
* Handle submenu position
20+
*/
21+
const menuItemsLvl0 = document.querySelectorAll(desktopMenuMap.menuItemsLvl0);
22+
23+
if (menuItemsLvl0) {
24+
menuItemsLvl0.forEach((element: HTMLElement) => {
25+
element.addEventListener('mouseenter', () => {
26+
const subMenuTopPosition = element.offsetHeight + element.offsetTop;
27+
const subMenu = element.querySelector(desktopMenuMap.subMenu) as HTMLElement;
28+
subMenu.style.top = `${subMenuTopPosition}px`;
29+
});
30+
});
31+
}
32+
1833
/**
1934
* Handle Mouse and Keyboard events for Submenus.
2035
* Find all dropdown toggles with [data-depth: ^2]

src/scss/custom/modules/_mainmenu.scss

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
}
77

88
&__tree {
9+
flex-wrap: wrap;
10+
911
> li {
1012
> a {
1113
padding: 1.5rem 1rem;
@@ -25,8 +27,9 @@
2527
left: 0;
2628
z-index: $zindex-offcanvas;
2729
display: none;
28-
padding: 0.725rem 0;
29-
background-color: #fff;
30+
padding: 1rem 0;
31+
background-color: var(--bs-white);
32+
border-top: 1px solid var(--bs-gray-200);
3033

3134
&.focusing,
3235
&:focus-within {

0 commit comments

Comments
 (0)