1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-02-15 07:25:54 +00:00

Fix position of tooltips in sidebar (#29203)

This commit is contained in:
Aidan Timson
2026-01-27 12:17:15 +00:00
committed by GitHub
parent 15b85d6f19
commit 4a2b7324f7

View File

@@ -418,21 +418,21 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
return html`<div class="panels-list"> return html`<div class="panels-list">
<div class="wrapper"> <div class="wrapper">
${renderList( ${renderList(
this._renderPanels(beforeSpacer, selectedPanel), this._renderPanels(beforeSpacer, selectedPanel),
"before-spacer", "before-spacer",
true true
)} )}
${this.renderScrollableFades()} ${this.renderScrollableFades()}
</div> </div>
${this._renderSpacer()} ${this._renderSpacer()}
${renderList( ${renderList(
html` html`
${this._renderPanels(afterSpacer, selectedPanel)} ${this._renderPanels(afterSpacer, selectedPanel)}
${this._renderFixedPanels(selectedPanel)} ${this._renderFixedPanels(selectedPanel)}
`, `,
"after-spacer", "after-spacer",
false false
)} )}
</div>`; </div>`;
} }
@@ -674,20 +674,13 @@ class HaSidebar extends SubscribeMixin(ScrollableFadeMixin(LitElement)) {
} }
} }
const tooltip = this._tooltip; const tooltip = this._tooltip;
const allListbox = this.shadowRoot!.querySelectorAll("ha-md-list")!; const itemRect = item.getBoundingClientRect();
const listbox = [...allListbox].find((lb) => lb.contains(item));
const top =
item.offsetTop +
11 +
(listbox?.offsetTop ?? 0) -
(listbox?.scrollTop ?? 0);
tooltip.innerText = itemText?.innerText ?? ""; tooltip.innerText = itemText?.innerText ?? "";
tooltip.style.display = "block"; tooltip.style.display = "block";
tooltip.style.position = "fixed"; tooltip.style.position = "fixed";
tooltip.style.top = `${top}px`; tooltip.style.top = `${itemRect.top + itemRect.height / 2 - tooltip.offsetHeight / 2}px`;
tooltip.style.left = `calc(${item.offsetLeft + item.clientWidth + 8}px + var(--safe-area-inset-left, 0px))`; tooltip.style.left = `calc(${itemRect.right + 8}px)`;
} }
private _hideTooltip() { private _hideTooltip() {