Get rid of the unwanted tooltip copying (#7408)

This commit is contained in:
Philip Allgaier 2020-10-22 23:57:52 +02:00 committed by Bram Kragten
parent bec0d9b00e
commit 0baaaefdf8

View File

@ -128,14 +128,24 @@ class SystemHealthCard extends LitElement {
}
private _copyInfo(): void {
// We have to copy title text and content separately, because
// copying the whole <ha-card> 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);