Skip to content

Commit

Permalink
Removing localnav wrapper if localnav fails to render
Browse files Browse the repository at this point in the history
  • Loading branch information
bandana147 committed Jan 13, 2025
1 parent 578fbd7 commit fe99f90
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,19 @@ class Gnav {
`;
};

removeLocalNav = () => {
lanaLog({ message: 'Gnav Localnav was removed, potential CLS' });
document.querySelector('.feds-localnav')?.remove();
return;
}

decorateLocalNav = async () => {
if (!this.isLocalNav()) return;
if (this.isLocalNav()) this.removeLocalNav();
const localNavItems = this.elements.navWrapper.querySelector('.feds-nav').querySelectorAll('.feds-navItem:not(.feds-navItem--section, .feds-navItem--mobile-only)');
const firstElem = localNavItems[0]?.querySelector('a') || localNavItems[0]?.querySelector('button');
if (!firstElem) {
lanaLog({ message: 'GNAV: Incorrect authoring of localnav found.', tags: 'errorType=info,module=gnav' });
return;
this.removeLocalNav();
}
const [title, navTitle = ''] = this.getOriginalTitle(firstElem);
let localNav = document.querySelector('.feds-localnav');
Expand Down

0 comments on commit fe99f90

Please sign in to comment.