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:
parent
a915f82aed
commit
5719f9017e
|
|
@ -93,6 +93,10 @@ function setup_custom_subtabs(wrapper, currentDoctype) {
|
||||||
const clonedLink = getTabLink(subtabClone);
|
const clonedLink = getTabLink(subtabClone);
|
||||||
clonedLink.removeAttr("href");
|
clonedLink.removeAttr("href");
|
||||||
clonedLink.attr("data-target-id", clonedLink.attr("aria-controls"));
|
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);
|
subtabClone.attr("data-parent-id", tabContentId);
|
||||||
|
|
||||||
subtabContainer.append(subtabClone);
|
subtabContainer.append(subtabClone);
|
||||||
|
|
@ -168,7 +172,15 @@ function setup_custom_subtabs(wrapper, currentDoctype) {
|
||||||
targetPane.addClass("active show");
|
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);
|
ensureParentChainVisible(subtabName);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue