Skip to content

Commit

Permalink
Allow tooltip to return undefined
Browse files Browse the repository at this point in the history
 tooltip: >
    [[[
        var show_buttoncard_tooltips= states['var.show_buttoncard_tooltips'].state;
        if (show_buttoncard_tooltips != "True")
          return undefined;
In order to prevent tooltips from showing you can return undefined like above.
  • Loading branch information
engelchrisi committed Dec 25, 2024
1 parent 08b7237 commit 3d36b10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
24 changes: 2 additions & 22 deletions .vscode/bookmarks.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
{
"files": [
{
"path": "dist/button-card.js",
"bookmarks": [
{
"line": 3841,
"column": 12,
"label": ""
},
{
"line": 3843,
"column": 20,
"label": ""
},
{
"line": 3926,
"column": 26,
"label": ""
}
]
},
{
"path": "src/button-card.ts",
"bookmarks": [
Expand All @@ -29,12 +9,12 @@
"label": ""
},
{
"line": 1013,
"line": 1015,
"column": 40,
"label": ""
},
{
"line": 1103,
"line": 1105,
"column": 47,
"label": ""
}
Expand Down
6 changes: 4 additions & 2 deletions src/button-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ class ButtonCard extends LitElement {
</style>
`
: html``;
let tooltipValue: string | undefined = undefined;
return html`
${extraStyles}
<div id="aspect-ratio" style=${styleMap(aspectRatio)}>
Expand Down Expand Up @@ -1008,10 +1009,11 @@ class ButtonCard extends LitElement {
</ha-card>
${this._getLock(lockStyle)}
</div>
${this._config?.tooltip
${this._config?.tooltip &&
(tooltipValue = this._getTemplateOrValue(this._stateObj, this._config.tooltip)) !== undefined
? html`
<span class="tooltiptext" style=${styleMap(tooltipStyleFromConfig)}>
${this._unsafeHTMLorNot(this._getTemplateOrValue(this._stateObj, this._config.tooltip))}
${this._unsafeHTMLorNot(tooltipValue)}
</span>
`
: ''}
Expand Down

0 comments on commit 3d36b10

Please sign in to comment.