@ecl/mega-menu 5.0.0-alpha.2 → 5.0.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mega-menu.js CHANGED
@@ -1,9 +1,7 @@
1
- /* eslint-disable class-methods-use-this */
2
-
3
1
  import { queryOne, queryAll } from '@ecl/dom-utils';
4
2
  import EventManager from '@ecl/event-manager';
5
- import isMobile from 'mobile-device-detect';
6
3
  import { createFocusTrap } from 'focus-trap';
4
+ import Bowser from 'bowser';
7
5
 
8
6
  /**
9
7
  * @param {HTMLElement} element DOM element for component instantiation and scope
@@ -138,7 +136,7 @@ export class MegaMenu {
138
136
  this.menuOverlay = null;
139
137
  this.currentItem = null;
140
138
  this.totalItemsWidth = 0;
141
- this.breakpointL = 996;
139
+ this.breakpointL = 1140;
142
140
  this.openPanel = { num: 0, item: {} };
143
141
  this.infoLinks = null;
144
142
  this.seeAllLinks = null;
@@ -361,9 +359,7 @@ export class MegaMenu {
361
359
  this.back.removeEventListener('click', this.handleClickOnBack);
362
360
  }
363
361
 
364
- if (this.attachClickListener) {
365
- document.removeEventListener('click', this.handleClickGlobal);
366
- }
362
+ document.removeEventListener('click', this.handleClickGlobal);
367
363
  }
368
364
 
369
365
  if (this.links) {
@@ -460,13 +456,17 @@ export class MegaMenu {
460
456
  * - not having hamburger menu on screen
461
457
  */
462
458
  useDesktopDisplay() {
459
+ const browser = Bowser.getParser(window.navigator.userAgent);
460
+ const isMobile = browser.getPlatformType() === 'mobile';
461
+ const isTablet = browser.getPlatformType() === 'tablet';
462
+
463
463
  // Detect mobile devices
464
- if (isMobile.isMobileOnly) {
464
+ if (isMobile) {
465
465
  return false;
466
466
  }
467
467
 
468
468
  // Force mobile display on tablet
469
- if (isMobile.isTablet) {
469
+ if (isTablet) {
470
470
  this.element.classList.add('ecl-mega-menu--forced-mobile');
471
471
  return false;
472
472
  }
@@ -492,14 +492,25 @@ export class MegaMenu {
492
492
 
493
493
  // Remove display:none from the sublists
494
494
  if (subLists && viewport === 'mobile') {
495
- const megaMenus = queryAll(
496
- '.ecl-mega-menu__item > .ecl-mega-menu__wrapper > .ecl-container > [data-ecl-mega-menu-mega]',
495
+ const megaMenus = queryAll('[data-ecl-mega-menu-mega]', this.element);
496
+ const featuredPanels = queryAll(
497
+ '[data-ecl-mega-menu-featured]',
497
498
  this.element,
498
499
  );
500
+ if (featuredPanels.length) {
501
+ megaMenus.push(...featuredPanels);
502
+ }
503
+
499
504
  megaMenus.forEach((menu) => {
500
505
  menu.style.height = '';
501
506
  });
502
507
 
508
+ if (subLists.length) {
509
+ subLists.forEach((list) => {
510
+ list.style.height = '';
511
+ });
512
+ }
513
+
503
514
  // Reset top position and height of the wrappers
504
515
  if (this.wrappers) {
505
516
  this.wrappers.forEach((wrapper) => {
@@ -578,7 +589,6 @@ export class MegaMenu {
578
589
  this.checkDropdownHeight(current);
579
590
  });
580
591
  } else {
581
- this.element.setAttribute('aria-expanded', 'false');
582
592
  this.element.removeAttribute('data-expanded');
583
593
  this.open.setAttribute('aria-expanded', 'false');
584
594
  this.enableScroll();
@@ -600,10 +610,10 @@ export class MegaMenu {
600
610
 
601
611
  if (viewport === 'desktop' && this.header) {
602
612
  if (this.headerBanner) {
603
- this.headerBanner.style.display = 'flex';
613
+ this.headerBanner.style.display = '';
604
614
  }
605
615
  if (this.headerNotification) {
606
- this.headerNotification.style.display = 'flex';
616
+ this.headerNotification.style.display = '';
607
617
  }
608
618
  }
609
619
  }
@@ -629,12 +639,12 @@ export class MegaMenu {
629
639
  screenWidth > this.breakpointL ? 'desktop' : 'mobile',
630
640
  );
631
641
  }
632
- if (this.prevScreenWidth > 1140 && screenWidth > 996) {
642
+ if (this.prevScreenWidth >= 1368 && screenWidth >= 1140) {
633
643
  this.resetStyles('desktop', true);
634
644
  }
635
645
  }
636
646
  this.isDesktop = this.useDesktopDisplay();
637
- this.isLarge = window.innerWidth > 1140;
647
+ this.isLarge = window.innerWidth >= 1368;
638
648
  // Update previous screen width
639
649
  this.prevScreenWidth = screenWidth;
640
650
  this.element.classList.remove('ecl-mega-menu--forced-mobile');
@@ -663,6 +673,11 @@ export class MegaMenu {
663
673
  checkDropdownHeight(menuItem, hide = true) {
664
674
  const infoPanel = queryOne('.ecl-mega-menu__info', menuItem);
665
675
  const mainPanel = queryOne('.ecl-mega-menu__mega', menuItem);
676
+ const expanded = queryOne('.ecl-mega-menu__subitem--expanded', menuItem);
677
+ let secondPanel = null;
678
+ if (expanded) {
679
+ secondPanel = queryOne('.ecl-mega-menu__mega--level-2', expanded);
680
+ }
666
681
  // Hide the panels while calculating their heights
667
682
  if (mainPanel && this.isDesktop && hide) {
668
683
  mainPanel.style.opacity = 0;
@@ -670,6 +685,10 @@ export class MegaMenu {
670
685
  if (infoPanel && this.isDesktop && hide) {
671
686
  infoPanel.style.opacity = 0;
672
687
  }
688
+ // Second panel has already zero opacity in reality, this is for consistency
689
+ if (secondPanel && this.isDesktop && hide) {
690
+ secondPanel.opacity = 0;
691
+ }
673
692
  setTimeout(() => {
674
693
  const viewportHeight = window.innerHeight;
675
694
  let infoPanelHeight = 0;
@@ -677,11 +696,12 @@ export class MegaMenu {
677
696
  if (this.isDesktop) {
678
697
  const heights = [];
679
698
  let height = 0;
680
- let secondPanel = null;
681
699
  let featuredPanel = null;
700
+ let featuredPanelFirst = null;
682
701
  let itemsHeight = 0;
683
702
  let subItemsHeight = 0;
684
703
  let featuredHeight = 0;
704
+ let featuredFirstHeight = 0;
685
705
 
686
706
  if (infoPanel) {
687
707
  infoPanel.style.height = '';
@@ -693,6 +713,7 @@ export class MegaMenu {
693
713
  itemsHeight = infoPanelHeight;
694
714
  subItemsHeight = infoPanelHeight;
695
715
  featuredHeight = infoPanelHeight;
716
+ featuredFirstHeight = infoPanelHeight;
696
717
  }
697
718
 
698
719
  if (mainPanel) {
@@ -723,39 +744,52 @@ export class MegaMenu {
723
744
  heights.push(itemsHeight);
724
745
  }
725
746
  }
747
+ featuredPanelFirst = queryOne(
748
+ ':scope > .ecl-mega-menu__featured',
749
+ mainPanel,
750
+ );
751
+ if (featuredPanelFirst) {
752
+ // Get the elements inside the scrollable container and calculate their heights.
753
+ Array.from(featuredPanelFirst.firstElementChild.children).forEach(
754
+ (child) => {
755
+ const elStyle = window.getComputedStyle(child);
756
+ const marginHeight =
757
+ parseFloat(elStyle.marginTop) +
758
+ parseFloat(elStyle.marginBottom);
759
+ featuredFirstHeight += child.offsetHeight + marginHeight;
760
+ },
761
+ );
762
+ // Add 8px to the featured panel height to prevent scrollbar
763
+ featuredFirstHeight += 8;
764
+ heights.push(featuredFirstHeight);
765
+ }
726
766
  }
727
- const expanded = queryOne(
728
- '.ecl-mega-menu__subitem--expanded',
729
- menuItem,
730
- );
731
-
732
- if (expanded) {
733
- secondPanel = queryOne('.ecl-mega-menu__mega--level-2', expanded);
734
- if (secondPanel) {
735
- secondPanel.style.height = '';
736
- const subItems = queryAll(`${this.subItemSelector}`, secondPanel);
737
- if (subItems.length > 0) {
738
- subItems.forEach((item) => {
739
- subItemsHeight += item.getBoundingClientRect().height;
740
- });
741
- }
742
- heights.push(subItemsHeight);
743
- // Featured panel calculations.
744
- featuredPanel = queryOne('.ecl-mega-menu__featured', expanded);
745
- if (featuredPanel) {
746
- // Get the elements inside the scrollable container and calculate their heights.
747
- Array.from(featuredPanel.firstElementChild.children).forEach(
748
- (child) => {
749
- const elStyle = window.getComputedStyle(child);
750
- const marginHeight =
751
- parseFloat(elStyle.marginTop) +
752
- parseFloat(elStyle.marginBottom);
753
- featuredHeight += child.offsetHeight + marginHeight;
754
- },
755
- );
756
767
 
757
- heights.push(featuredHeight);
758
- }
768
+ if (secondPanel) {
769
+ secondPanel.style.height = '';
770
+ const subItems = queryAll(`${this.subItemSelector}`, secondPanel);
771
+ if (subItems.length > 0) {
772
+ subItems.forEach((item) => {
773
+ subItemsHeight += item.getBoundingClientRect().height;
774
+ });
775
+ }
776
+ heights.push(subItemsHeight);
777
+ // Featured panel calculations.
778
+ featuredPanel = queryOne('.ecl-mega-menu__featured', expanded);
779
+ if (featuredPanel) {
780
+ // Get the elements inside the scrollable container and calculate their heights.
781
+ Array.from(featuredPanel.firstElementChild.children).forEach(
782
+ (child) => {
783
+ const elStyle = window.getComputedStyle(child);
784
+ const marginHeight =
785
+ parseFloat(elStyle.marginTop) +
786
+ parseFloat(elStyle.marginBottom);
787
+ featuredHeight += child.offsetHeight + marginHeight;
788
+ },
789
+ );
790
+ // Add 5px to the featured panel height to prevent scrollbar on hover
791
+ featuredHeight += 5;
792
+ heights.push(featuredHeight);
759
793
  }
760
794
  }
761
795
 
@@ -764,6 +798,11 @@ export class MegaMenu {
764
798
  const containerBottom = containerBounding.bottom;
765
799
  // By requirements, limit the height to the 70% of the available space.
766
800
  const availableHeight = (window.innerHeight - containerBottom) * 0.7;
801
+ const minHeight =
802
+ parseFloat(
803
+ window.getComputedStyle(queryOne('.ecl-mega-menu__wrapper'))
804
+ .minHeight,
805
+ ) || 0;
767
806
 
768
807
  if (maxHeight > availableHeight) {
769
808
  height = availableHeight;
@@ -771,10 +810,15 @@ export class MegaMenu {
771
810
  height = maxHeight;
772
811
  }
773
812
 
813
+ if (height < minHeight) {
814
+ height = minHeight;
815
+ }
816
+
774
817
  const wrapper = queryOne('.ecl-mega-menu__wrapper', menuItem);
775
818
  if (wrapper) {
776
819
  wrapper.style.height = `${height}px`;
777
820
  }
821
+
778
822
  if (mainPanel && this.isLarge) {
779
823
  mainPanel.style.height = `${height}px`;
780
824
  } else if (mainPanel && infoPanel && this.isDesktop) {
@@ -788,6 +832,11 @@ export class MegaMenu {
788
832
  } else if (secondPanel && this.isDesktop) {
789
833
  secondPanel.style.height = `${height - infoPanelHeight}px`;
790
834
  }
835
+ if (featuredPanelFirst && this.isLarge) {
836
+ featuredPanelFirst.style.height = `${height}px`;
837
+ } else if (featuredPanelFirst && this.isDesktop) {
838
+ featuredPanelFirst.style.height = `${height - infoPanelHeight}px`;
839
+ }
791
840
  if (featuredPanel && this.isLarge) {
792
841
  featuredPanel.style.height = `${height}px`;
793
842
  } else if (featuredPanel && this.isDesktop) {
@@ -800,6 +849,9 @@ export class MegaMenu {
800
849
  if (infoPanel && this.isDesktop) {
801
850
  infoPanel.style.opacity = 1;
802
851
  }
852
+ if (secondPanel && this.isDesktop) {
853
+ secondPanel.style.opacity = 1;
854
+ }
803
855
  }, 100);
804
856
  }
805
857
 
@@ -824,46 +876,62 @@ export class MegaMenu {
824
876
  const item = queryOne('.ecl-mega-menu__item--expanded', this.element);
825
877
 
826
878
  if (item) {
827
- const subList = queryOne('.ecl-mega-menu__sublist', item);
828
- if (subList && this.openPanel.num === 1) {
829
- const info = queryOne('.ecl-mega-menu__info', item);
830
- if (info) {
831
- const bottomRect = info.getBoundingClientRect();
832
- const bottomInfo = bottomRect.bottom;
833
- availableHeight = window.innerHeight - bottomInfo - 16;
879
+ const hasFeatured = queryOne(
880
+ '.ecl-mega-menu__mega--has-featured',
881
+ item,
882
+ );
883
+ const info = queryOne('.ecl-mega-menu__info', item);
884
+ if (info && this.openPanel.num === 1) {
885
+ const bottomRect = info.getBoundingClientRect();
886
+ const bottomInfo = bottomRect.bottom;
887
+ availableHeight = window.innerHeight - bottomInfo - 16;
888
+ }
889
+ if (hasFeatured) {
890
+ const hasFeaturedRect = hasFeatured.getBoundingClientRect();
891
+ const hasFeaturedTop = hasFeaturedRect.top;
892
+ availableHeight =
893
+ availableHeight || window.innerHeight - hasFeaturedTop;
894
+ hasFeatured.style.height = `${availableHeight}px`;
895
+ } else {
896
+ const subList = queryOne('.ecl-mega-menu__sublist', item);
897
+ if (subList && this.openPanel.num === 1) {
898
+ const subListRect = subList.getBoundingClientRect();
899
+ const subListRectTop = subListRect.top;
834
900
  subList.classList.add('ecl-mega-menu__sublist--scrollable');
901
+ availableHeight =
902
+ availableHeight || window.innerHeight - subListRectTop;
835
903
  subList.style.height = `${availableHeight}px`;
904
+ } else if (subList) {
905
+ subList.classList.remove('ecl-mega-menu__sublist--scrollable');
906
+ subList.style.height = '';
836
907
  }
837
- } else if (subList) {
838
- subList.classList.remove('ecl-mega-menu__sublist--scrollable');
839
- subList.style.height = '';
840
- }
841
- }
842
908
 
843
- if (this.openPanel.num === 2) {
844
- const subItem = queryOne(
845
- '.ecl-mega-menu__subitem--expanded',
846
- this.element,
847
- );
848
- if (subItem) {
849
- const subMega = queryOne(
850
- '.ecl-mega-menu__mega--level-2',
851
- subItem,
852
- );
853
- if (subMega) {
854
- const subMegaRect = subMega.getBoundingClientRect();
855
- const subMegaTop = subMegaRect.top;
856
- availableHeight = window.innerHeight - subMegaTop;
857
- subMega.style.height = `${availableHeight}px`;
909
+ if (this.openPanel.num === 2) {
910
+ const subItem = queryOne(
911
+ '.ecl-mega-menu__subitem--expanded',
912
+ this.element,
913
+ );
914
+ if (subItem) {
915
+ const subMega = queryOne(
916
+ '.ecl-mega-menu__mega--level-2',
917
+ subItem,
918
+ );
919
+ if (subMega) {
920
+ const subMegaRect = subMega.getBoundingClientRect();
921
+ const subMegaTop = subMegaRect.top;
922
+ availableHeight = window.innerHeight - subMegaTop;
923
+ subMega.style.height = `${availableHeight}px`;
924
+ }
925
+ }
926
+ }
927
+ if (this.wrappers) {
928
+ this.wrappers.forEach((wrapper) => {
929
+ wrapper.style.top = '';
930
+ wrapper.style.height = '';
931
+ });
858
932
  }
859
933
  }
860
934
  }
861
- if (this.wrappers) {
862
- this.wrappers.forEach((wrapper) => {
863
- wrapper.style.top = '';
864
- wrapper.style.height = '';
865
- });
866
- }
867
935
  }
868
936
  }, 0);
869
937
  } else {
@@ -903,7 +971,7 @@ export class MegaMenu {
903
971
  handleKeyboard(e) {
904
972
  const element = e.target;
905
973
  const cList = element.classList;
906
- const menuExpanded = this.element.getAttribute('aria-expanded');
974
+ const menuExpanded = this.element.getAttribute('data-expanded');
907
975
 
908
976
  // Detect press on Escape
909
977
  if (e.key === 'Escape' || e.key === 'Esc') {
@@ -911,7 +979,7 @@ export class MegaMenu {
911
979
  element.blur();
912
980
  }
913
981
 
914
- if (menuExpanded === 'false') {
982
+ if (!menuExpanded) {
915
983
  this.closeOpenDropdown();
916
984
  }
917
985
  return;
@@ -1155,7 +1223,7 @@ export class MegaMenu {
1155
1223
  } else {
1156
1224
  e.preventDefault();
1157
1225
  this.disableScroll();
1158
- this.element.setAttribute('aria-expanded', 'true');
1226
+ this.element.setAttribute('data-expanded', true);
1159
1227
  this.element.classList.add('ecl-mega-menu--start-panel');
1160
1228
  this.element.classList.remove(
1161
1229
  'ecl-mega-menu--one-panel',
@@ -1197,7 +1265,7 @@ export class MegaMenu {
1197
1265
  * @fires Menu#onClose
1198
1266
  */
1199
1267
  handleClickOnClose(e) {
1200
- if (this.element.getAttribute('aria-expanded') === 'true') {
1268
+ if (this.element.getAttribute('data-expanded')) {
1201
1269
  this.focusTrap.deactivate();
1202
1270
  this.closeOpenDropdown();
1203
1271
  this.trigger('onClose', e);
@@ -1238,6 +1306,7 @@ export class MegaMenu {
1238
1306
  'ecl-mega-menu--start-panel',
1239
1307
  );
1240
1308
  this.element.classList.add('ecl-mega-menu--one-panel');
1309
+ this.element.classList.remove('ecl-mega-menu--has-secondary-featured');
1241
1310
  level2.setAttribute('aria-expanded', 'false');
1242
1311
  level2.classList.remove(
1243
1312
  'ecl-mega-menu__subitem--expanded',
@@ -1263,10 +1332,10 @@ export class MegaMenu {
1263
1332
  } else {
1264
1333
  if (this.header) {
1265
1334
  if (this.headerBanner) {
1266
- this.headerBanner.style.display = 'flex';
1335
+ this.headerBanner.style.display = '';
1267
1336
  }
1268
1337
  if (this.headerNotification) {
1269
- this.headerNotification.style.display = 'flex';
1338
+ this.headerNotification.style.display = '';
1270
1339
  }
1271
1340
  }
1272
1341
  // Remove expanded class from inner menu
@@ -1291,9 +1360,9 @@ export class MegaMenu {
1291
1360
  if (this.header) {
1292
1361
  this.header.classList.add('ecl-site-header--open-menu-start');
1293
1362
  }
1294
- this.positionMenuOverlay();
1295
1363
  }
1296
1364
 
1365
+ this.positionMenuOverlay();
1297
1366
  this.trigger('onBack', { level: level2 ? 2 : 1 });
1298
1367
  }
1299
1368
 
@@ -1312,7 +1381,6 @@ export class MegaMenu {
1312
1381
  this.positionMenuOverlay();
1313
1382
  this.checkDropdownHeight(menuItem);
1314
1383
  this.element.setAttribute('data-expanded', true);
1315
- this.element.setAttribute('aria-expanded', 'true');
1316
1384
  this.element.classList.add('ecl-mega-menu--one-panel');
1317
1385
  this.element.classList.remove('ecl-mega-menu--start-panel');
1318
1386
  this.open.setAttribute('aria-expanded', 'true');
@@ -1360,19 +1428,6 @@ export class MegaMenu {
1360
1428
  };
1361
1429
  const details = { panel: 1, item: menuItem };
1362
1430
  this.trigger('OnOpenPanel', details);
1363
- if (this.isDesktop) {
1364
- const list = queryOne('.ecl-mega-menu__sublist', menuItem);
1365
- if (list) {
1366
- // Expand the item in the sublist if it contains children.
1367
- const firstExpandedChild = Array.from(list.children).find((child) =>
1368
- child.firstElementChild?.hasAttribute('aria-expanded'),
1369
- );
1370
-
1371
- if (firstExpandedChild) {
1372
- this.handleSecondPanel(firstExpandedChild, 'expand', true);
1373
- }
1374
- }
1375
- }
1376
1431
  break;
1377
1432
  }
1378
1433
 
@@ -1392,7 +1447,7 @@ export class MegaMenu {
1392
1447
  *
1393
1448
  * @fires MegaMenu#onOpenPanel
1394
1449
  */
1395
- handleSecondPanel(menuItem, op, noCheck = false) {
1450
+ handleSecondPanel(menuItem, op) {
1396
1451
  const infoPanel = queryOne(
1397
1452
  '.ecl-mega-menu__info',
1398
1453
  menuItem.closest('.ecl-container'),
@@ -1410,17 +1465,30 @@ export class MegaMenu {
1410
1465
  if (item === menuItem) {
1411
1466
  if (itemLink && itemLink.hasAttribute('aria-expanded')) {
1412
1467
  itemLink.setAttribute('aria-expanded', 'true');
1413
-
1468
+ const mega = queryOne('.ecl-mega-menu__mega', item);
1414
1469
  if (!this.isDesktop) {
1415
1470
  // We use this class mainly to recover the default behavior of the link.
1416
1471
  itemLink.classList.add('ecl-mega-menu__parent-link');
1417
1472
  if (this.back) {
1418
1473
  this.back.focus();
1419
1474
  }
1475
+ } else {
1476
+ // Hide the panel since it will be resized later.
1477
+ mega.style.opacity = 0;
1420
1478
  }
1421
1479
  item.classList.add('ecl-mega-menu__subitem--expanded');
1422
1480
  }
1423
1481
  item.classList.add('ecl-mega-menu__subitem--current');
1482
+ const hasFeatured = queryOne('.ecl-mega-menu__featured', item);
1483
+ if (hasFeatured) {
1484
+ this.element.classList.add(
1485
+ 'ecl-mega-menu--has-secondary-featured',
1486
+ );
1487
+ } else {
1488
+ this.element.classList.remove(
1489
+ 'ecl-mega-menu--has-secondary-featured',
1490
+ );
1491
+ }
1424
1492
  this.backItemLevel2 = item;
1425
1493
  } else {
1426
1494
  if (itemLink && itemLink.hasAttribute('aria-expanded')) {
@@ -1450,12 +1518,11 @@ export class MegaMenu {
1450
1518
  });
1451
1519
  }
1452
1520
  this.positionMenuOverlay();
1453
- if (!noCheck) {
1454
- this.checkDropdownHeight(
1455
- menuItem.closest('.ecl-mega-menu__item'),
1456
- false,
1457
- );
1458
- }
1521
+ this.checkDropdownHeight(
1522
+ menuItem.closest('.ecl-mega-menu__item'),
1523
+ false,
1524
+ );
1525
+
1459
1526
  const details = { panel: 2, item: menuItem };
1460
1527
  this.trigger('OnOpenPanel', details);
1461
1528
  break;
@@ -1463,6 +1530,7 @@ export class MegaMenu {
1463
1530
 
1464
1531
  case 'collapse':
1465
1532
  this.element.classList.remove('ecl-mega-menu--two-panels');
1533
+ this.element.classList.remove('ecl-mega-menu--has-secondary-featured');
1466
1534
  this.openPanel = { num: 1 };
1467
1535
  // eslint-disable-next-line no-case-declarations
1468
1536
  const itemLink = queryOne(this.subLinkSelector, menuItem);
@@ -1474,6 +1542,12 @@ export class MegaMenu {
1474
1542
  if (infoPanel) {
1475
1543
  infoPanel.style.top = '';
1476
1544
  }
1545
+
1546
+ this.positionMenuOverlay();
1547
+ this.checkDropdownHeight(
1548
+ menuItem.closest('.ecl-mega-menu__item'),
1549
+ false,
1550
+ );
1477
1551
  break;
1478
1552
 
1479
1553
  default:
@@ -1560,20 +1634,20 @@ export class MegaMenu {
1560
1634
  * @fires MegaMenu#onFocusTrapToggle
1561
1635
  */
1562
1636
  closeOpenDropdown(esc = false) {
1637
+ this.element.classList.remove('ecl-mega-menu--has-secondary-featured');
1563
1638
  if (this.header) {
1564
1639
  this.header.classList.remove(
1565
1640
  'ecl-site-header--open-menu',
1566
1641
  'ecl-site-header--open-menu-start',
1567
1642
  );
1568
1643
  if (this.headerBanner) {
1569
- this.headerBanner.style.display = 'flex';
1644
+ this.headerBanner.style.display = '';
1570
1645
  }
1571
1646
  if (this.headerNotification) {
1572
- this.headerNotification.style.display = 'flex';
1647
+ this.headerNotification.style.display = '';
1573
1648
  }
1574
1649
  }
1575
1650
  this.enableScroll();
1576
- this.element.setAttribute('aria-expanded', 'false');
1577
1651
  this.element.removeAttribute('data-expanded');
1578
1652
  this.element.classList.remove(
1579
1653
  'ecl-mega-menu--start-panel',
@@ -1626,7 +1700,7 @@ export class MegaMenu {
1626
1700
  sublists.forEach((sublist) => {
1627
1701
  sublist.classList.remove(
1628
1702
  'ecl-mega-menu__sublist--no-border',
1629
- '.ecl-mega-menu__sublist--scrollable',
1703
+ 'ecl-mega-menu__sublist--scrollable',
1630
1704
  );
1631
1705
  });
1632
1706
  }
@@ -1660,11 +1734,11 @@ export class MegaMenu {
1660
1734
  */
1661
1735
  handleFocusOut(e) {
1662
1736
  const element = e.target;
1663
- const menuExpanded = this.element.getAttribute('aria-expanded');
1737
+ const menuExpanded = this.element.getAttribute('data-expanded');
1664
1738
 
1665
1739
  // Specific focus action for mobile menu
1666
1740
  // Loop through the items and go back to close button
1667
- if (menuExpanded === 'true' && !this.isDesktop) {
1741
+ if (menuExpanded && !this.isDesktop) {
1668
1742
  const nextItem = element.parentElement.nextSibling;
1669
1743
 
1670
1744
  if (!nextItem) {