From e8f052faf3b5f671c1490600942cfc2c17bf8356 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sun, 29 Mar 2026 11:07:16 +0200 Subject: [PATCH] Fixed drag/drop on application-sheet --- .../sheets/api/application-mixin.mjs | 35 ++++++------------- .../global/partials/inventory-item-V2.hbs | 2 +- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/module/applications/sheets/api/application-mixin.mjs b/module/applications/sheets/api/application-mixin.mjs index 83313454..64f62405 100644 --- a/module/applications/sheets/api/application-mixin.mjs +++ b/module/applications/sheets/api/application-mixin.mjs @@ -79,8 +79,6 @@ export default function DHApplicationMixin(Base) { */ constructor(options = {}) { super(options); - - this._setupDragDrop(); } /** @@ -175,9 +173,6 @@ export default function DHApplicationMixin(Base) { _attachPartListeners(partId, htmlElement, options) { super._attachPartListeners(partId, htmlElement, options); - /* Core dragDrop from ActorDocument is always only 1. Possible we could refactor our own */ - if (Array.isArray(this._dragDrop)) this._dragDrop.forEach(d => d.bind(htmlElement)); - // Handle delta inputs for (const deltaInput of htmlElement.querySelectorAll('input[data-allow-delta]')) { deltaInput.dataset.numValue = deltaInput.value; @@ -289,6 +284,16 @@ export default function DHApplicationMixin(Base) { async _onRender(context, options) { await super._onRender(context, options); this._createTagifyElements(this.options.tagifyConfigs); + + for (const d of this.options.dragDrop) { + new foundry.applications.ux.DragDrop.implementation({ + ...d, + callbacks: { + dragstart: this._onDragStart.bind(this), + drop: this._onDrop.bind(this) + } + }).bind(this.element); + } } /* -------------------------------------------- */ @@ -349,26 +354,6 @@ export default function DHApplicationMixin(Base) { /* Drag and Drop */ /* -------------------------------------------- */ - /** - * Creates drag-drop handlers from the configured options. - * @returns {foundry.applications.ux.DragDrop[]} - * @private - */ - _setupDragDrop() { - if (this._dragDrop) { - this._dragDrop.callbacks.dragStart = this._onDragStart; - this._dragDrop.callback.drop = this._onDrop; - } else { - this._dragDrop = this.options.dragDrop.map(d => { - d.callbacks = { - dragstart: this._onDragStart.bind(this), - drop: this._onDrop.bind(this) - }; - return new foundry.applications.ux.DragDrop.implementation(d); - }); - } - } - /** * Handle dragStart event. * @param {DragEvent} event diff --git a/templates/sheets/global/partials/inventory-item-V2.hbs b/templates/sheets/global/partials/inventory-item-V2.hbs index a758a28f..2129b969 100644 --- a/templates/sheets/global/partials/inventory-item-V2.hbs +++ b/templates/sheets/global/partials/inventory-item-V2.hbs @@ -17,7 +17,7 @@ Parameters: - showActions {boolean} : If true show feature's actions. --}} -