From 5cf9e982dd6d810899c9ade8421f41dba88af728 Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Mon, 12 Jan 2026 18:57:01 +0400 Subject: [PATCH] subtab bug fix --- custom_subtabs/public/js/custom_subtabs.js | 33 ++++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/custom_subtabs/public/js/custom_subtabs.js b/custom_subtabs/public/js/custom_subtabs.js index c380ad5..3ff4eea 100644 --- a/custom_subtabs/public/js/custom_subtabs.js +++ b/custom_subtabs/public/js/custom_subtabs.js @@ -169,24 +169,34 @@ function setup_custom_subtabs(wrapper, currentDoctype) { // Function to setup main tab handler function setupMainTabHandler() { - wrapper.off("shown.bs.tab.customsubtabs") - .on("shown.bs.tab.customsubtabs", "button.nav-link:not(.sub-tab button.nav-link), a.nav-link:not(.sub-tab a.nav-link)", function(event) { - + // Удаляем старый обработчик + wrapper.off("shown.bs.tab.customsubtabs"); + + // Регистрируем новый на wrapper без делегирования + wrapper.on("shown.bs.tab.customsubtabs", function(event) { const button = event.target; - const tabId = button.getAttribute("aria-controls"); - const li = $(button).closest("li.nav-item"); - + const $button = $(button); + const li = $button.closest("li.nav-item"); + // If this is a subtab - ignore if (li.hasClass("sub-tab")) { return; } - + + const tabId = button.getAttribute("aria-controls"); + + console.log('shown.bs.tab сработал для:', { + text: $button.text().trim(), + tabId: tabId, + isSubtab: li.hasClass("sub-tab") + }); + // ИСПРАВЛЕНИЕ: Убираем active классы со всех субтабов и их контента wrapper.find(".sub-tab").removeClass("active"); wrapper.find(".sub-tab button.nav-link, .sub-tab a.nav-link") .removeClass("active") .attr("aria-selected", "false"); - + // Скрываем контент всех субтабов wrapper.find(".sub-tab").each(function() { const subtabButton = getTabLink($(this)); @@ -195,10 +205,15 @@ function setup_custom_subtabs(wrapper, currentDoctype) { $(`#${subtabContentId}`).removeClass("active show"); } }); - + // Show/hide subtabs wrapper.find(".sub-tab-container").each(function() { const containerParentId = $(this).attr("data-parent-id"); + console.log('Проверка контейнера:', { + containerParentId: containerParentId, + tabId: tabId, + match: containerParentId === tabId + }); if (containerParentId === tabId) { $(this).removeClass("subtab-hidden"); } else {