From edc2a03d1c4cd0e43aa194b644d9a581e6ab2057 Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Thu, 22 Oct 2020 23:57:52 +0200 Subject: [PATCH] Get rid of the unwanted tooltip copying (#7408) --- src/panels/config/info/system-health-card.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/panels/config/info/system-health-card.ts b/src/panels/config/info/system-health-card.ts index b3433a0831..13b9b80e2b 100644 --- a/src/panels/config/info/system-health-card.ts +++ b/src/panels/config/info/system-health-card.ts @@ -128,14 +128,24 @@ 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(); - const copyElement = this.shadowRoot?.querySelector( - "ha-card" + let copyElement = this.shadowRoot?.querySelector( + ".card-header-text" ) as HTMLElement; - const range = document.createRange(); + let range = document.createRange(); + range.selectNodeContents(copyElement); + selection.addRange(range); + + copyElement = this.shadowRoot?.querySelector( + ".card-content" + ) as HTMLElement; + + range = document.createRange(); range.selectNodeContents(copyElement); selection.addRange(range);