mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-17 14:26:35 +00:00
Get rid of the unwanted tooltip copying (final) (#7459)
This commit is contained in:
parent
ba99d1a10d
commit
58a58906e7
@ -72,7 +72,7 @@ class SystemHealthCard extends LitElement {
|
|||||||
}
|
}
|
||||||
if (domain !== "homeassistant") {
|
if (domain !== "homeassistant") {
|
||||||
sections.push(
|
sections.push(
|
||||||
html` <h3>${domainToName(this.hass.localize, domain)}</h3> `
|
html`<h3>${domainToName(this.hass.localize, domain)}</h3>`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
sections.push(html`
|
sections.push(html`
|
||||||
@ -128,30 +128,27 @@ class SystemHealthCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _copyInfo(): void {
|
private _copyInfo(): void {
|
||||||
// We have to copy title text and content separately, because
|
const copyElement = this.shadowRoot?.querySelector(
|
||||||
// copying the whole <ha-card> 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(
|
|
||||||
".card-content"
|
".card-content"
|
||||||
) as HTMLElement;
|
) 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);
|
range.selectNodeContents(copyElement);
|
||||||
selection.addRange(range);
|
selection.addRange(range);
|
||||||
|
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
window.getSelection()!.removeAllRanges();
|
window.getSelection()!.removeAllRanges();
|
||||||
|
|
||||||
|
// Remove temporary heading again
|
||||||
|
copyElement.removeChild(tempTitle);
|
||||||
|
|
||||||
this._toolTip!.show();
|
this._toolTip!.show();
|
||||||
setTimeout(() => this._toolTip?.hide(), 3000);
|
setTimeout(() => this._toolTip?.hide(), 3000);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user