diff --git a/src/panels/config/info/system-health-card.ts b/src/panels/config/info/system-health-card.ts index 13b9b80e2b..69df18b5b5 100644 --- a/src/panels/config/info/system-health-card.ts +++ b/src/panels/config/info/system-health-card.ts @@ -72,7 +72,7 @@ class SystemHealthCard extends LitElement { } if (domain !== "homeassistant") { sections.push( - html`

${domainToName(this.hass.localize, domain)}

` + html`

${domainToName(this.hass.localize, domain)}

` ); } sections.push(html` @@ -128,30 +128,27 @@ class SystemHealthCard extends LitElement { } private _copyInfo(): void { - // We have to copy title text and content separately, because - // copying the whole would also copy the tooltip text. - const selection = window.getSelection()!; - selection.removeAllRanges(); - - let copyElement = this.shadowRoot?.querySelector( - ".card-header-text" - ) as HTMLElement; - - let range = document.createRange(); - range.selectNodeContents(copyElement); - selection.addRange(range); - - copyElement = this.shadowRoot?.querySelector( + const copyElement = this.shadowRoot?.querySelector( ".card-content" ) as HTMLElement; - range = document.createRange(); + // Add temporary heading (fixed in EN since usually executed to provide support data) + const tempTitle = document.createElement("h3"); + tempTitle.innerText = "System Health"; + copyElement.insertBefore(tempTitle, copyElement.firstElementChild); + + const selection = window.getSelection()!; + selection.removeAllRanges(); + const range = document.createRange(); range.selectNodeContents(copyElement); selection.addRange(range); document.execCommand("copy"); window.getSelection()!.removeAllRanges(); + // Remove temporary heading again + copyElement.removeChild(tempTitle); + this._toolTip!.show(); setTimeout(() => this._toolTip?.hide(), 3000); }