diff --git a/module/applications/sheets/api/application-mixin.mjs b/module/applications/sheets/api/application-mixin.mjs index bdd9fa68..5e186c86 100644 --- a/module/applications/sheets/api/application-mixin.mjs +++ b/module/applications/sheets/api/application-mixin.mjs @@ -203,11 +203,19 @@ export default function DHApplicationMixin(Base) { this.relatedDocs.filter(doc => doc).map(doc => delete doc.apps[this.id]); } + /** @inheritdoc */ + async _renderHTML(context, options) { + const rendered = await super._renderHTML(context, options); + for (const result of Object.values(rendered)) { + await this.#prepareInventoryDescription(result); + } + return rendered; + } + /**@inheritdoc */ async _onRender(context, options) { await super._onRender(context, options); this._createTagifyElements(this.options.tagifyConfigs); - await this.#prepareInventoryDescription(context); } /* -------------------------------------------- */ @@ -215,8 +223,8 @@ export default function DHApplicationMixin(Base) { /* -------------------------------------------- */ /**@inheritdoc */ - _syncPartState(partId, newElement, priorElement, state) { - super._syncPartState(partId, newElement, priorElement, state); + _preSyncPartState(partId, newElement, priorElement, state) { + super._preSyncPartState(partId, newElement, priorElement, state); for (const el of priorElement.querySelectorAll('.extensible.extended')) { const { actionId, itemUuid } = el.parentElement.dataset; const selector = `${actionId ? `[data-action-id="${actionId}"]` : `[data-item-uuid="${itemUuid}"]`} .extensible`; @@ -496,11 +504,12 @@ export default function DHApplicationMixin(Base) { /** * Prepares and enriches an inventory item or action description for display. + * @param {HTMLElement} element the element to enrich the inventory items of * @returns {Promise} */ - async #prepareInventoryDescription(context) { + async #prepareInventoryDescription(element) { // Get all inventory item elements with a data-item-uuid attribute - const inventoryItems = this.element.querySelectorAll('.inventory-item[data-item-uuid]'); + const inventoryItems = element.querySelectorAll('.inventory-item[data-item-uuid]'); for (const el of inventoryItems) { // Get the doc uuid from the element const { itemUuid } = el?.dataset || {};