REFACTOR: move _createSearchFilter from CharacterSheet#_onFirstRender to CharacterSheet#_onRender (#267)

Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com>
This commit is contained in:
joaquinpereyra98 2025-07-05 05:26:35 -03:00 committed by GitHub
parent 9d76405221
commit 0add5f369e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -211,17 +211,18 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
return { primary: primaryTabs, secondary: secondaryTabs };
}
/**@inheritdoc */
async _onFirstRender(context, options) {
await super._onFirstRender(context, options);
this._createContextMenues();
this._createFilterMenus();
}
/** @inheritDoc */
async _onRender(context, options) {
await super._onRender(context, options);
this._createFilterMenus();
this._createSearchFilter();
}
@ -409,6 +410,10 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
}
};
/* -------------------------------------------- */
/* Search Inputs */
/* -------------------------------------------- */
/**
* Create and initialize search filter instances for the inventory and loadout sections.
*
@ -485,18 +490,6 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
}
}
static async rollAttribute(event, button) {
const abilityLabel = game.i18n.localize(abilities[button.dataset.attribute].label);
const config = {
event: event,
title: game.i18n.format('DAGGERHEART.Chat.DualityRoll.AbilityCheckTitle', { ability: abilityLabel }),
roll: {
trait: button.dataset.attribute
}
};
this.document.diceRoll(config);
}
/* -------------------------------------------- */
/* Filter Menus */
/* -------------------------------------------- */
@ -571,6 +564,7 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
li.hidden = !(search.has(item.id) && matchesMenu);
}
}
/* -------------------------------------------- */
async mapFeatureType(data, configType) {
@ -593,6 +587,18 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
);
}
static async rollAttribute(event, button) {
const abilityLabel = game.i18n.localize(abilities[button.dataset.attribute].label);
const config = {
event: event,
title: game.i18n.format('DAGGERHEART.Chat.DualityRoll.AbilityCheckTitle', { ability: abilityLabel }),
roll: {
trait: button.dataset.attribute
}
};
this.document.diceRoll(config);
}
static async toggleMarks(_, button) {
const markValue = Number.parseInt(button.dataset.value);
const newValue = this.document.system.armor.system.marks.value >= markValue ? markValue - 1 : markValue;