Larkinabout / fvtt-token-action-hud-core

Token Action HUD is a repositionable HUD of actions for a selected token.
14 stars 22 forks source link

[BUG] Tooltips on subgroup images render as [object Object] #291

Closed sferguson12 closed 2 weeks ago

sferguson12 commented 2 weeks ago

Describe the bug

When hovering over the images displayed next to Strike subgroups, the tooltip renders incorrectly as [object Object] instead of the actual tooltip.

image

Since the tooltip is being converted to an object in getTooltip() in tooltip-handler.mjs, this appears to be an issue in the list-subgroup.hbs template in how the tooltip is being set.

{{~#if (ne selected false)~}}
<div class="tah-subgroup tah-list-subgroup" data-nest-id="{{nestId}}" data-part="subgroup" data-has-actions="{{~#if (tokenActionHudCoreTrue hasActions)~}}true{{~else~}}false{{~/if~}}" data-has-image="{{~#if (tokenActionHudCoreTrue settings.image)~}}true{{~else~}}false{{~/if~}}" data-level="{{level}}" data-type="{{type}}" data-show-title="{{settings.showTitle}}">
-    {{~#if settings.image~}}<img class="tah-list-image{{~#if (tokenActionHudCoreTrue settings.collapse)}} tah-hidden{{~/if}}" src="{{settings.image}}" {{~#if tooltip~}} data-tooltip="{{tooltip}}" data-tooltip-class="tah-tooltip"{{~/if~}}>{{~/if~}}
+    {{~#if settings.image~}}<img class="tah-list-image{{~#if (tokenActionHudCoreTrue settings.collapse)}} tah-hidden{{~/if}}" src="{{settings.image}}" {{~#if tooltip~}} data-tooltip="{{tooltip.content}}" data-tooltip-class="tah-tooltip"{{~/if~}}>{{~/if~}}
    <div class="tah-list-subgroup{{~#if class}} {{class}}{{~/if~}}" data-part="listSubgroup">
        <div class="tah-list-subgroup-title{{~#if subtitleClass}} {{subtitleClass}}{{~/if~}}" data-action="clickSubgroup" data-part="listSubgroupTitle">

The current state results in this being added to the DOM:

<img class="tah-list-image" src="systems/pf2e/icons/unarmed-attacks/jaws.webp" data-tooltip="[object Object]" data-tooltip-class="tah-tooltip"><div class="tah-list-subgroup" data-part="listSubgroup">

Which renders as this on hover:

<aside id="tooltip" role="tooltip" data-theme="crb" style="top: 348.812px; left: 168.5px;" class="tah-tooltip text-center">[object Object]</aside>

This issue also appears to exist in tab-subgroup.hbs and group.hbs if an image is present.

Steps to reproduce

  1. Load a scene with an actor that has one or more Strike actions with icons
  2. Select the actor
  3. Wait for the HUD to load
  4. Mouse over Strikes
  5. Mouse over the image for a specific Strike

Expected: The tooltip for that Strike should render Actual: A tooltip containing "[object Object]" renders

Versions:

Larkinabout commented 2 weeks ago

Fixed in 2.0.7. Thanks for looking into it.

sferguson12 commented 2 weeks ago

Not sure if this slipped by in the report above, but I noticed the same issue in tab-subgroup.hbs and group.hbs and it looks like only list-subgroup.hbs was updated in the commit.