Skip to content

Commit

Permalink
updating all tabs on the page
Browse files Browse the repository at this point in the history
  • Loading branch information
AlfieJones committed Jun 10, 2024
1 parent 6ca822f commit 7352aed
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion apps/marketing-astro/src/components/schema/tabs.astro
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,28 @@ const group = labels.sort().toString();
activePanel = document.getElementById(tabId)!;
activePanel.removeAttribute("hidden");

localStorage.setItem(`tabs-${groupID}-active`, String(index));
if (localStorage.getItem(`tabs-${groupID}-active`) !== String(index)) {
localStorage.setItem(`tabs-${groupID}-active`, String(index));

const event = new CustomEvent(`tabs-${groupID}-change`);
document.dispatchEvent(event);
}

activeTrigger = trigger;
}

triggers.forEach((trigger, i) => {
trigger.addEventListener("click", () => setActiveTab(trigger, i));
});
document.addEventListener(`tabs-${groupID}-change`, () => {
const index = localStorage.getItem(`tabs-${groupID}-active`);
setActiveTab(
triggers.item(index ? parseInt(index) : 0),
parseInt(index || "0")
);

console.log("adsf");
});
const index = localStorage.getItem(`tabs-${groupID}-active`);
setActiveTab(
triggers.item(index ? parseInt(index) : 0),
Expand Down

0 comments on commit 7352aed

Please sign in to comment.