[Fix] Updating item quantity in party inventory (#1378)

* Fix updating item quantity in party inventory

* Remove unnecessary second render
This commit is contained in:
Carlos Fernandez 2025-12-07 04:39:40 -08:00 committed by GitHub
parent 14ac8977af
commit 28976bb4b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 12 deletions

View file

@ -134,6 +134,10 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
htmlElement.querySelectorAll('.inventory-item-quantity').forEach(element => {
element.addEventListener('change', this.updateItemQuantity.bind(this));
element.addEventListener('click', e => e.stopPropagation());
});
htmlElement.querySelectorAll('.item-button .action-uses-button').forEach(element => {
element.addEventListener('contextmenu', DHBaseActorSheet.#modifyActionUses);
});
@ -172,6 +176,15 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) {
return this._getContextMenuCommonOptions.call(this, { usable: true, toChat: true });
}
/* -------------------------------------------- */
/* Application Listener Actions */
/* -------------------------------------------- */
async updateItemQuantity(event) {
const item = await getDocFromElement(event.currentTarget);
await item?.update({ 'system.quantity': event.currentTarget.value });
}
/* -------------------------------------------- */
/* Application Clicks Actions */
/* -------------------------------------------- */