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 GitHub
parent 174f8f5823
commit edc2a03d1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);