Skip to content

Commit

Permalink
fix issue with subitems & helitems
Browse files Browse the repository at this point in the history
  • Loading branch information
reonZ committed Jul 5, 2024
1 parent 25d84b3 commit 38f2d3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/hud/sidebar/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class PF2eHudSidebarItems extends PF2eHudSidebar {
},
};

console.log(inventoryData);

return data;
}

Expand Down Expand Up @@ -174,14 +176,18 @@ async function openCarryTypeMenu(actor: CharacterPF2e, anchor: HTMLElement): Pro
}

function getItemFilter(itemData: SidebarItem): string {
if (itemData.item.subitems.size) {
return `${itemData.item.name} ` + itemData.item.subitems.map((x) => x.name).join(" ");
}

if (!itemData.heldItems?.length) return itemData.item.name;

itemData.heldItems = itemData.heldItems.map((x) => {
x.filterValue = getItemFilter(x);
return x;
});

return itemData.heldItems.map((x) => x.filterValue).join(" ");
return `${itemData.item.name} ` + itemData.heldItems.map((x) => x.filterValue).join(" ");
}

type SidebarItem = Omit<InventoryItem, "heldItems"> & {
Expand Down
2 changes: 1 addition & 1 deletion templates/sidebars/items.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="item{{#if hidden}} hidden-item{{/if}}{{#if item.isTemporary}} temporary{{/if}}" {{#if
isSubitem}} data-parent-id="{{item.parentItem.id}}" {{/if}} data-item-id="{{item.id}}" {{#if
isContainer}}data-is-container{{/if}} {{#if item.isInContainer}}data-item-type="{{item.type}}"
{{/if}} draggable="true" data-filter-value="{{filterValue}}">
{{/if}} draggable="true" data-filter-value="{{ifThen isSubitem item.name filterValue}}">
{{!-- subspacer --}}
{{#if (or item.isInContainer isSubitem)}}
{{#if (and item.isInContainer isContainer)}}
Expand Down

0 comments on commit 38f2d3d

Please sign in to comment.