feat: add persistent active tab tracking to actor sheet
This commit is contained in:
parent
df8c94a21f
commit
bcc263cc5e
1 changed files with 24 additions and 10 deletions
|
@ -48,6 +48,11 @@ export class DS4ActorSheet extends foundry.applications.api.DocumentSheetV2 {
|
|||
|
||||
static TABS = {};
|
||||
|
||||
constructor(options = {}) {
|
||||
super(options);
|
||||
this.activeTab = "values"; // Default active tab
|
||||
}
|
||||
|
||||
get title() {
|
||||
return `${this.document.name} [${game.i18n.localize("DS4.ActorSheet")}]`;
|
||||
}
|
||||
|
@ -502,6 +507,9 @@ export class DS4ActorSheet extends foundry.applications.api.DocumentSheetV2 {
|
|||
const tab = target.dataset.tab;
|
||||
if (!tab) return;
|
||||
|
||||
// Store the active tab
|
||||
this.activeTab = tab;
|
||||
|
||||
// Find tab navigation elements
|
||||
const nav = target.closest(".ds4-sheet-tab-nav");
|
||||
const sheet = this.element.querySelector(".ds4-sheet-body");
|
||||
|
@ -552,18 +560,24 @@ export class DS4ActorSheet extends foundry.applications.api.DocumentSheetV2 {
|
|||
navItems.forEach(item => item.classList.remove("active"));
|
||||
tabContents.forEach(content => content.classList.remove("active"));
|
||||
|
||||
// Set first tab navigation as active
|
||||
const firstNavItem = navItems[0];
|
||||
if (firstNavItem) {
|
||||
firstNavItem.classList.add("active");
|
||||
// Find the currently active tab or default to first
|
||||
let targetTab = this.activeTab;
|
||||
let targetNavItem = nav.querySelector(`[data-tab="${targetTab}"]`);
|
||||
|
||||
// If stored tab doesn't exist, fall back to first tab
|
||||
if (!targetNavItem) {
|
||||
targetNavItem = navItems[0];
|
||||
targetTab = targetNavItem?.dataset.tab;
|
||||
}
|
||||
|
||||
// Set target tab navigation as active
|
||||
if (targetNavItem && targetTab) {
|
||||
targetNavItem.classList.add("active");
|
||||
|
||||
// Set corresponding tab content as active
|
||||
const firstTab = firstNavItem.dataset.tab;
|
||||
if (firstTab) {
|
||||
const activeTabContent = sheet.querySelector(`.ds4-sheet-tab[data-tab="${firstTab}"]`);
|
||||
if (activeTabContent) {
|
||||
activeTabContent.classList.add("active");
|
||||
}
|
||||
const activeTabContent = sheet.querySelector(`.ds4-sheet-tab[data-tab="${targetTab}"]`);
|
||||
if (activeTabContent) {
|
||||
activeTabContent.classList.add("active");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue