diff --git a/src/module/sheet/helpers.ts b/src/module/sheet/helpers.ts index 0df9728362d..8e0355d89d1 100644 --- a/src/module/sheet/helpers.ts +++ b/src/module/sheet/helpers.ts @@ -42,12 +42,15 @@ function createTagifyTraits(traits: Iterable, { sourceTraits, record }: return [...traitSlugs, ...hiddenTraits] .map((slug) => { const label = game.i18n.localize(record?.[slug] ?? slug); + const traitDescriptions: Record = CONFIG.PF2E.traitsDescriptions; + const tooltip = traitDescriptions[slug]; return { id: slug, value: label, readonly: readonlyTraits.has(slug), // Must be undefined for tagify to work hidden: !traitSlugs.has(slug) || undefined, + "data-tooltip": tooltip, }; }) .sort((t1, t2) => t1.value.localeCompare(t2.value)); @@ -229,6 +232,7 @@ interface TagifyEntry { * Tagify treats any value as true, even false or null. */ hidden?: true; + "data-tooltip"?: string; } export { diff --git a/src/styles/_tags.scss b/src/styles/_tags.scss index 7edad29a00c..1de8394f64a 100644 --- a/src/styles/_tags.scss +++ b/src/styles/_tags.scss @@ -85,6 +85,16 @@ } } +// Allow tags to recieve events and disable just the rarity dropdown +tags.tagify { + &[disabled] { + pointer-events: inherit; + select.tag.rarity { + pointer-events: none; + } + } +} + // Tagify and non-tagify paizo style main traits row .tags.paizo-style { border: none; diff --git a/src/util/tags.ts b/src/util/tags.ts index b2d177393bb..4eb100707a8 100644 --- a/src/util/tags.ts +++ b/src/util/tags.ts @@ -30,6 +30,20 @@ function transformWhitelist(whitelist: WhitelistData) { .sort((a, b) => a.value.localeCompare(b.value, game.i18n.lang)); } +function getTagifyTagTemplate(tagify: Tagify, tagData: TagRecord): string { + return ` + +
+ ${tagData[tagify.settings.tagTextProp] || tagData.value} +
+
`; +} + /** Create a tagify select menu out of a JSON input element */ function tagify(element: HTMLInputElement, options?: TagifyOptions): Tagify; function tagify(element: HTMLTagifyTagsElement, options?: TagifyOptions): Tagify; @@ -66,6 +80,12 @@ function tagify( editTags, delimiters, whitelist: whitelistTransformed, + templates: { + tag(tagData: TagRecord) { + // Default template without title to prevent the default tag tooltip from showing. + return getTagifyTagTemplate(this, tagData); + }, + }, }); DestroyableManager.instance.observe(tagify);