fix: keep subtab bar visible on subtab click (drop cloned Frappe handler)

clone(true) copied Frappe's per-nav-link click handler (tab.js -> set_active)
onto the subtab buttons, so every subtab click also ran set_active(), which
deactivates the parent tab pane that physically contains the subtab buttons.
Our handler then had to undo it by reconstructing the parent pane id from the
(translated) label — fragile.

Drop the copied handler on cloned subtab links, and restore the parent pane
by its reliable data-parent-id instead of label string-building.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ali 2026-06-16 09:46:45 +00:00
parent a915f82aed
commit 5719f9017e
1 changed files with 13 additions and 1 deletions

View File

@ -93,6 +93,10 @@ function setup_custom_subtabs(wrapper, currentDoctype) {
const clonedLink = getTabLink(subtabClone);
clonedLink.removeAttr("href");
clonedLink.attr("data-target-id", clonedLink.attr("aria-controls"));
// clone(true) копирует прямой обработчик Frappe (tab.js: nav-link.on('click') ->
// set_active()), который деактивирует РОДИТЕЛЬСКУЮ панель — а в ней лежат сами
// кнопки субтабов. Снимаем его: кликами по субтабам управляем своей делегацией.
clonedLink.off("click");
subtabClone.attr("data-parent-id", tabContentId);
subtabContainer.append(subtabClone);
@ -168,7 +172,15 @@ function setup_custom_subtabs(wrapper, currentDoctype) {
targetPane.addClass("active show");
}
// Show parent chain
// Надёжно вернуть РОДИТЕЛЬСКУЮ панель (в ней живут кнопки субтабов) по её реальному
// id из data-parent-id — НЕ реконструируя id из перевода label'а. Это и есть защита
// от «все субтабы пропали»: панель с кнопками всегда восстанавливается.
const parentPane = $(`#${parentContainerId}`);
if (parentPane.length) {
parentPane.addClass("active show").css("display", "block");
}
// Show parent chain (для вложенности глубже одного уровня)
ensureParentChainVisible(subtabName);
});