mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-16 05:46: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") {
|
||||
sections.push(
|
||||
html` <h3>${domainToName(this.hass.localize, domain)}</h3> `
|
||||
html`<h3>${domainToName(this.hass.localize, domain)}</h3>`
|
||||
);
|
||||
}
|
||||
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 <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(
|
||||
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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user