Fixed drag/drop on application-sheet

This commit is contained in:
WBHarry 2026-03-29 11:07:16 +02:00
parent 740216ada2
commit e8f052faf3
2 changed files with 11 additions and 26 deletions

View file

@ -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

View file

@ -17,7 +17,7 @@ Parameters:
- showActions {boolean} : If true show feature's actions.
--}}
<li class="inventory-item" data-item-id="{{item.id}}"
<li class="inventory-item" data-item-id="{{item.id}}"
{{#if (or (eq type 'action' ) (eq type 'attack' ))}}data-action-id="{{item.id}}" {{/if}}
{{#if disabledEffect}}data-disabled="true"{{/if}}
data-type="{{type}}" data-item-type="{{item.type}}"