From 96d1903dccdaaf33a0c4a93ecd56bc5c8633b9e2 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <118168183+sharmrj@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:07:02 +0530 Subject: [PATCH] Added Analytics Attributes to Tabs and Tabpanels (#3275) * Added analytics attributes to tabs and tabpanels * Handle cases where we don't find daa attributes --- .../global-navigation/utilities/utilities.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libs/blocks/global-navigation/utilities/utilities.js b/libs/blocks/global-navigation/utilities/utilities.js index 5cfa5e944d..d6053691b9 100644 --- a/libs/blocks/global-navigation/utilities/utilities.js +++ b/libs/blocks/global-navigation/utilities/utilities.js @@ -398,16 +398,19 @@ export const [setUserProfile, getUserProfile] = (() => { export const transformTemplateToMobile = async (popup, item, localnav = false) => { const notMegaMenu = popup.parentElement.tagName === 'DIV'; - if (notMegaMenu) return; + if (notMegaMenu) return null; const originalContent = popup.innerHTML; const tabs = [...popup.querySelectorAll('.feds-menu-section')] .filter((section) => !section.querySelector('.feds-promo') && section.textContent) .map((section) => { - const name = section.querySelector('.feds-menu-headline')?.textContent ?? 'Shop For'; + const headline = section.querySelector('.feds-menu-headline'); + const name = headline?.textContent ?? 'Shop For'; + const daallTab = headline?.getAttribute('daa-ll'); + const daalhTabContent = section.querySelector('.feds-menu-items')?.getAttribute('daa-lh'); const content = section.querySelector('.feds-menu-items') ?? section; const links = [...content.querySelectorAll('a.feds-navLink')].map((x) => x.outerHTML).join(''); - return { name, links }; + return { name, links, daallTab, daalhTabContent }; }); const CTA = popup.querySelector('.feds-cta')?.outerHTML ?? ''; const mainMenu = ` @@ -433,21 +436,23 @@ export const transformTemplateToMobile = async (popup, item, localnav = false) = ${item.textContent.trim()}
- ${tabs.map(({ name }, i) => ` + ${tabs.map(({ name, daallTab }, i) => ` `).join('')}
- ${tabs.map(({ links }, i) => ` + ${tabs.map(({ links, daalhTabContent }, i) => `