From d15d5f98563d9eed3ff08bd97c317a9cbb2ff3ce Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 2 Oct 2020 16:53:00 -0700 Subject: [PATCH] Set tabbed_container data-active-tab-id on tab change. --- frontends/etiquette_flask/static/js/common.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontends/etiquette_flask/static/js/common.js b/frontends/etiquette_flask/static/js/common.js index 0714281..4e1fc98 100644 --- a/frontends/etiquette_flask/static/js/common.js +++ b/frontends/etiquette_flask/static/js/common.js @@ -439,6 +439,7 @@ function init_tabbed_container(tabbed_container) button_container.append(button); } tabs[0].classList.remove("hidden"); + tabbed_container.dataset.activeTabId = tabs[0].dataset.tabId; button_container.firstElementChild.classList.remove("tab_button_inactive"); button_container.firstElementChild.classList.add("tab_button_active"); } @@ -474,7 +475,6 @@ function tabbed_container_switcher(event) const tab_id = tab_button.dataset.tabId; const tab_buttons = tab_button.parentElement.getElementsByClassName("tab_button"); - const tabs = tab_button.parentElement.parentElement.getElementsByClassName("tab"); for (const tab_button of tab_buttons) { if (tab_button.dataset.tabId === tab_id) @@ -488,6 +488,9 @@ function tabbed_container_switcher(event) tab_button.classList.add("tab_button_inactive"); } } + const tabbed_container = tab_button.closest(".tabbed_container"); + tabbed_container.dataset.activeTabId = tab_id; + const tabs = tabbed_container.getElementsByClassName("tab"); for (const tab of tabs) { if (tab.dataset.tabId === tab_id)