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 = {}) { constructor(options = {}) {
super(options); super(options);
this._setupDragDrop();
} }
/** /**
@ -175,9 +173,6 @@ export default function DHApplicationMixin(Base) {
_attachPartListeners(partId, htmlElement, options) { _attachPartListeners(partId, htmlElement, options) {
super._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 // Handle delta inputs
for (const deltaInput of htmlElement.querySelectorAll('input[data-allow-delta]')) { for (const deltaInput of htmlElement.querySelectorAll('input[data-allow-delta]')) {
deltaInput.dataset.numValue = deltaInput.value; deltaInput.dataset.numValue = deltaInput.value;
@ -289,6 +284,16 @@ export default function DHApplicationMixin(Base) {
async _onRender(context, options) { async _onRender(context, options) {
await super._onRender(context, options); await super._onRender(context, options);
this._createTagifyElements(this.options.tagifyConfigs); 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 */ /* 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. * Handle dragStart event.
* @param {DragEvent} event * @param {DragEvent} event