Compare commits

..

1 Commits

Author SHA1 Message Date
Aidan Timson
5650733b62 Migrate config-thread dialog(s) to wa 2026-02-05 15:38:03 +00:00
5 changed files with 39 additions and 72 deletions

View File

@@ -4,7 +4,7 @@ import { fireEvent } from "../../../../../common/dom/fire_event";
import type { HassDialog } from "../../../../../dialogs/make-dialog-manager";
import type { HomeAssistant } from "../../../../../types";
import type { DialogThreadDatasetParams } from "./show-dialog-thread-dataset";
import { createCloseHeading } from "../../../../../components/ha-dialog";
import "../../../../../components/ha-wa-dialog";
@customElement("ha-dialog-thread-dataset")
class DialogThreadDataset extends LitElement implements HassDialog {
@@ -12,16 +12,22 @@ class DialogThreadDataset extends LitElement implements HassDialog {
@state() private _params?: DialogThreadDatasetParams;
@state() private _open = false;
public async showDialog(
params: DialogThreadDatasetParams
): Promise<Promise<void>> {
this._params = params;
this._open = true;
}
public closeDialog() {
this._open = false;
}
private _dialogClosed() {
this._params = undefined;
fireEvent(this, "dialog-closed", { dialog: this.localName });
return true;
}
protected render() {
@@ -37,10 +43,11 @@ class DialogThreadDataset extends LitElement implements HassDialog {
dataset.extended_pan_id &&
otbrInfo.active_dataset_tlvs?.includes(dataset.extended_pan_id);
return html`<ha-dialog
open
@closed=${this.closeDialog}
.heading=${createCloseHeading(this.hass, network.name)}
return html`<ha-wa-dialog
.hass=${this.hass}
.open=${this._open}
header-title=${network.name}
@closed=${this._dialogClosed}
>
<div>
Network name: ${dataset.network_name}<br />
@@ -54,7 +61,7 @@ class DialogThreadDataset extends LitElement implements HassDialog {
Active dataset TLVs: ${otbrInfo.active_dataset_tlvs}`
: nothing}
</div>
</ha-dialog>`;
</ha-wa-dialog>`;
}
}

View File

@@ -635,12 +635,8 @@ class HUIRoot extends LitElement {
`;
}
private _handleContainerScroll = () => {
const viewRoot = this._viewRoot;
this.toggleAttribute(
"scrolled",
viewRoot ? viewRoot.scrollTop !== 0 : false
);
private _handleWindowScroll = () => {
this.toggleAttribute("scrolled", window.scrollY !== 0);
};
private _locationChanged = () => {
@@ -671,7 +667,7 @@ class HUIRoot extends LitElement {
protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps);
this._viewRoot?.addEventListener("scroll", this._handleContainerScroll, {
window.addEventListener("scroll", this._handleWindowScroll, {
passive: true,
});
this._handleUrlChanged();
@@ -682,7 +678,7 @@ class HUIRoot extends LitElement {
public connectedCallback(): void {
super.connectedCallback();
this._viewRoot?.addEventListener("scroll", this._handleContainerScroll, {
window.addEventListener("scroll", this._handleWindowScroll, {
passive: true,
});
window.addEventListener("popstate", this._handlePopState);
@@ -693,14 +689,10 @@ class HUIRoot extends LitElement {
public disconnectedCallback(): void {
super.disconnectedCallback();
this._viewRoot?.removeEventListener("scroll", this._handleContainerScroll);
window.removeEventListener("scroll", this._handleWindowScroll);
window.removeEventListener("popstate", this._handlePopState);
window.removeEventListener("location-changed", this._locationChanged);
const viewRoot = this._viewRoot;
this.toggleAttribute(
"scrolled",
viewRoot ? viewRoot.scrollTop !== 0 : false
);
this.toggleAttribute("scrolled", window.scrollY !== 0);
// Re-enable history scroll restoration when leaving the page
window.history.scrollRestoration = "auto";
}
@@ -833,12 +825,9 @@ class HUIRoot extends LitElement {
(this._restoreScroll && this._viewScrollPositions[newSelectView]) ||
0;
this._restoreScroll = false;
requestAnimationFrame(() => {
const viewRoot = this._viewRoot;
if (viewRoot) {
viewRoot.scrollTo({ behavior: "auto", top: position });
}
});
requestAnimationFrame(() =>
scrollTo({ behavior: "auto", top: position })
);
}
this._selectView(newSelectView, force);
});
@@ -1163,7 +1152,7 @@ class HUIRoot extends LitElement {
const path = this.config.views[viewIndex].path || viewIndex;
this._navigateToView(path);
} else if (!this._editMode) {
this._viewRoot?.scrollTo({ behavior: "smooth", top: 0 });
scrollTo({ behavior: "smooth", top: 0 });
}
}
@@ -1174,8 +1163,7 @@ class HUIRoot extends LitElement {
// Save scroll position of current view
if (this._curView != null) {
const viewRoot = this._viewRoot;
this._viewScrollPositions[this._curView] = viewRoot?.scrollTop ?? 0;
this._viewScrollPositions[this._curView] = window.scrollY;
}
viewIndex = viewIndex === undefined ? 0 : viewIndex;
@@ -1481,14 +1469,9 @@ class HUIRoot extends LitElement {
hui-view-container {
position: relative;
display: flex;
height: calc(
100vh - var(--header-height) - var(--safe-area-inset-top) - var(
--view-container-padding-top,
0px
)
);
min-height: 100vh;
box-sizing: border-box;
margin-top: calc(
padding-top: calc(
var(--header-height) + var(--safe-area-inset-top) +
var(--view-container-padding-top, 0px)
);
@@ -1511,12 +1494,7 @@ class HUIRoot extends LitElement {
* In edit mode we have the tab bar on a new line *
*/
hui-view-container.has-tab-bar {
height: calc(
100vh - var(--header-height, 56px) - calc(
var(--tab-bar-height, 56px) - 2px
) - var(--safe-area-inset-top, 0px)
);
margin-top: calc(
padding-top: calc(
var(--header-height, 56px) +
calc(var(--tab-bar-height, 56px) - 2px) +
var(--safe-area-inset-top, 0px)

View File

@@ -407,20 +407,12 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
}
}
private _getScrollContainer(): Element | null {
// The scroll container is the hui-view-container parent
return this.closest("hui-view-container");
}
private _toggleView() {
const scrollContainer = this._getScrollContainer();
const scrollTop = scrollContainer?.scrollTop ?? 0;
// Save current scroll position
if (this._sidebarTabActive) {
this._sidebarScrollTop = scrollTop;
this._sidebarScrollTop = window.scrollY;
} else {
this._contentScrollTop = scrollTop;
this._contentScrollTop = window.scrollY;
}
this._sidebarTabActive = !this._sidebarTabActive;
@@ -436,7 +428,7 @@ export class SectionsView extends LitElement implements LovelaceViewElement {
const scrollY = this._sidebarTabActive
? this._sidebarScrollTop
: this._contentScrollTop;
scrollContainer?.scrollTo(0, scrollY);
window.scrollTo(0, scrollY);
});
}

View File

@@ -4,7 +4,6 @@ import { customElement, property, state } from "lit/decorators";
import { applyThemesOnElement } from "../../../common/dom/apply_themes_on_element";
import { listenMediaQuery } from "../../../common/dom/media_query";
import type { LovelaceViewConfig } from "../../../data/lovelace/config/view";
import { haStyleScrollbar } from "../../../resources/styles";
import type { HomeAssistant } from "../../../types";
type BackgroundConfig = LovelaceViewConfig["background"];
@@ -23,7 +22,6 @@ class HuiViewContainer extends LitElement {
public connectedCallback(): void {
super.connectedCallback();
this.classList.add("ha-scrollbar");
this._setUpMediaQuery();
this._applyTheme();
}
@@ -76,16 +74,11 @@ class HuiViewContainer extends LitElement {
}
}
static styles = [
haStyleScrollbar,
css`
:host {
display: block;
height: 100%;
-webkit-overflow-scrolling: touch;
}
`,
];
static styles = css`
:host {
display: relative;
}
`;
}
declare global {

View File

@@ -224,20 +224,17 @@ export const haStyleDialogFixedTop = css`
`;
export const haStyleScrollbar = css`
.ha-scrollbar::-webkit-scrollbar,
:host(.ha-scrollbar)::-webkit-scrollbar {
.ha-scrollbar::-webkit-scrollbar {
width: 0.4rem;
height: 0.4rem;
}
.ha-scrollbar::-webkit-scrollbar-thumb,
:host(.ha-scrollbar)::-webkit-scrollbar-thumb {
.ha-scrollbar::-webkit-scrollbar-thumb {
border-radius: var(--ha-border-radius-sm);
background: var(--scrollbar-thumb-color);
}
.ha-scrollbar,
:host(.ha-scrollbar) {
.ha-scrollbar {
overflow-y: auto;
scrollbar-color: var(--scrollbar-thumb-color) transparent;
scrollbar-width: thin;