From a168d8de652622094aa8cde8ca1d31b7ff0092c0 Mon Sep 17 00:00:00 2001 From: Nick Salyzyn Date: Tue, 23 Dec 2025 06:14:55 -0700 Subject: [PATCH] [PR] Changing the drag targets in the inventory item v2 template (#1443) * Adding styles to make the text div take up the full area of the inventory items * Moving the draggable spots to internal divs and images * For better visuals in dragDrop, always make the drag image the first image selected * Fixing the dragDrop behavior on the sidebar, which still uses the classic layout * Fixing other uses of dragDrop to handle the layout change * Moving the draggable attribute to the parent img-portrait from img directly * Switching to the less pretty version of the drag drop in case of currency problems * Reverting how the dragSelector DEFAULT_OPTION is set and only modifying a few * Removing extra space in styles/less/global/inventory-item.less Co-authored-by: Carlos Fernandez * Fixing up the character sheet to once again allow selecting the text areas --------- Co-authored-by: Carlos Fernandez --- module/applications/sheets/actors/adversary.mjs | 2 +- module/applications/sheets/actors/character.mjs | 11 ++++++++++- module/applications/sheets/actors/party.mjs | 2 +- module/applications/sheets/api/base-actor.mjs | 2 +- styles/less/global/inventory-item.less | 3 ++- .../sheets/global/partials/inventory-item-V2.hbs | 6 +++--- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/module/applications/sheets/actors/adversary.mjs b/module/applications/sheets/actors/adversary.mjs index 6b6354ef..345f6fed 100644 --- a/module/applications/sheets/actors/adversary.mjs +++ b/module/applications/sheets/actors/adversary.mjs @@ -26,7 +26,7 @@ export default class AdversarySheet extends DHBaseActorSheet { } ] }, - dragDrop: [{ dragSelector: '[data-item-id][draggable="true"]', dropSelector: null }] + dragDrop: [{ dragSelector: '[data-item-id]', dropSelector: null }] }; static PARTS = { diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index 51df2fc9..66ed6315 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -46,7 +46,7 @@ export default class CharacterSheet extends DHBaseActorSheet { }, dragDrop: [ { - dragSelector: '[data-item-id][draggable="true"]', + dragSelector: '[data-item-id][draggable="true"], [data-item-id] [draggable="true"]', dropSelector: null } ], @@ -868,6 +868,15 @@ export default class CharacterSheet extends DHBaseActorSheet { }); } + /** @inheritdoc */ + async _onDragStart(event) { + const inventoryItem = event.currentTarget.closest('.inventory-item'); + if (inventoryItem) { + event.dataTransfer.setDragImage(inventoryItem.querySelector('img'), 60, 0); + } + super._onDragStart(event); + } + async _onDropItem(event, item) { if (this.document.uuid === item.parent?.uuid) { return super._onDropItem(event, item); diff --git a/module/applications/sheets/actors/party.mjs b/module/applications/sheets/actors/party.mjs index 5c448b49..d78519cb 100644 --- a/module/applications/sheets/actors/party.mjs +++ b/module/applications/sheets/actors/party.mjs @@ -40,7 +40,7 @@ export default class Party extends DHBaseActorSheet { selectRefreshable: DaggerheartMenu.selectRefreshable, refreshActors: DaggerheartMenu.refreshActors }, - dragDrop: [{ dragSelector: '[data-item-id][draggable="true"]', dropSelector: null }] + dragDrop: [{ dragSelector: '[data-item-id]', dropSelector: null }] }; /**@override */ diff --git a/module/applications/sheets/api/base-actor.mjs b/module/applications/sheets/api/base-actor.mjs index 5d054949..85ecd616 100644 --- a/module/applications/sheets/api/base-actor.mjs +++ b/module/applications/sheets/api/base-actor.mjs @@ -374,4 +374,4 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) { super._onDragStart(event); } -} \ No newline at end of file +} diff --git a/styles/less/global/inventory-item.less b/styles/less/global/inventory-item.less index d936358b..c8a29795 100644 --- a/styles/less/global/inventory-item.less +++ b/styles/less/global/inventory-item.less @@ -129,7 +129,8 @@ .item-label { flex: 1; - align-self: center; + align-self: stretch; + align-content: center; .item-name { font-size: var(--font-size-14); diff --git a/templates/sheets/global/partials/inventory-item-V2.hbs b/templates/sheets/global/partials/inventory-item-V2.hbs index 91f8d581..dbacd1e4 100644 --- a/templates/sheets/global/partials/inventory-item-V2.hbs +++ b/templates/sheets/global/partials/inventory-item-V2.hbs @@ -18,12 +18,12 @@ Parameters: --}}
  • + data-action-id="{{item.id}}" {{/if}} data-item-uuid="{{item.uuid}}" data-type="{{type}}" data-no-compendium-edit="{{noCompendiumEdit}}">
    {{!-- Image --}}
    + data-tooltip="#attack#{{item.actor.uuid}}" {{else}} data-tooltip="#item#{{item.uuid}}" {{/if}} {{/unless}} draggable="true"> {{#if (or item.system.actionsList.size item.system.actionsList.length item.actionType)}} {{#if @root.isNPC}} @@ -35,7 +35,7 @@ Parameters:
    {{!-- Name & Tags --}} -
    +
    {{!-- Item Name --}} {{localize item.name}} {{#unless (or noExtensible (not item.system.description))}}{{/unless}}