1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00

scroll to top when installing an update

This commit is contained in:
Christoph
2025-07-08 10:10:28 +02:00
parent a6304d6284
commit d0051b0c4c
2 changed files with 19 additions and 1 deletions

View File

@@ -29,6 +29,13 @@ import {
} from "../../../data/update"; } from "../../../data/update";
import type { HomeAssistant } from "../../../types"; import type { HomeAssistant } from "../../../types";
import { showAlertDialog } from "../../generic/show-dialog-box"; import { showAlertDialog } from "../../generic/show-dialog-box";
import { fireEvent } from "../../../common/dom/fire_event";
declare global {
interface HASSDomEvents {
"more-info-update-clicked": undefined;
}
}
@customElement("more-info-update") @customElement("more-info-update")
class MoreInfoUpdate extends LitElement { class MoreInfoUpdate extends LitElement {
@@ -406,6 +413,8 @@ class MoreInfoUpdate extends LitElement {
} }
this.hass.callService("update", "install", installData); this.hass.callService("update", "install", installData);
fireEvent(this, "more-info-update-clicked");
} }
private _createBackupChanged(ev) { private _createBackupChanged(ev) {

View File

@@ -12,7 +12,7 @@ import {
import type { HassEntity } from "home-assistant-js-websocket"; import type { HassEntity } from "home-assistant-js-websocket";
import type { PropertyValues } from "lit"; import type { PropertyValues } from "lit";
import { LitElement, css, html, nothing } from "lit"; import { LitElement, css, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state, query } from "lit/decorators";
import { cache } from "lit/directives/cache"; import { cache } from "lit/directives/cache";
import { join } from "lit/directives/join"; import { join } from "lit/directives/join";
import { dynamicElement } from "../../common/dom/dynamic-element-directive"; import { dynamicElement } from "../../common/dom/dynamic-element-directive";
@@ -50,6 +50,7 @@ import { getSensorNumericDeviceClasses } from "../../data/sensor";
import { haStyleDialog } from "../../resources/styles"; import { haStyleDialog } from "../../resources/styles";
import "../../state-summary/state-card-content"; import "../../state-summary/state-card-content";
import type { HomeAssistant } from "../../types"; import type { HomeAssistant } from "../../types";
import type { HaDialog } from "../../components/ha-dialog";
import { import {
DOMAINS_WITH_MORE_INFO, DOMAINS_WITH_MORE_INFO,
EDITABLE_DOMAINS_WITH_ID, EDITABLE_DOMAINS_WITH_ID,
@@ -112,6 +113,8 @@ export class MoreInfoDialog extends LitElement {
@state() private _sensorNumericDeviceClasses?: string[] = []; @state() private _sensorNumericDeviceClasses?: string[] = [];
@query("ha-dialog") private _dialog?: HaDialog;
public showDialog(params: MoreInfoDialogParams) { public showDialog(params: MoreInfoDialogParams) {
this._entityId = params.entityId; this._entityId = params.entityId;
if (!this._entityId) { if (!this._entityId) {
@@ -271,6 +274,11 @@ export class MoreInfoDialog extends LitElement {
this._infoEditMode = ev.detail; this._infoEditMode = ev.detail;
} }
private _handleScrollToTopEvent(ev: Event): void {
ev.stopPropagation();
this._dialog!.scrollToPos(0, 0);
}
private _goToRelated(ev): void { private _goToRelated(ev): void {
if (!shouldHandleRequestSelectedEvent(ev)) return; if (!shouldHandleRequestSelectedEvent(ev)) return;
this._setView("related"); this._setView("related");
@@ -521,6 +529,7 @@ export class MoreInfoDialog extends LitElement {
@show-child-view=${this._showChildView} @show-child-view=${this._showChildView}
@entity-entry-updated=${this._entryUpdated} @entity-entry-updated=${this._entryUpdated}
@toggle-edit-mode=${this._handleToggleInfoEditModeEvent} @toggle-edit-mode=${this._handleToggleInfoEditModeEvent}
@more-info-update-clicked=${this._handleScrollToTopEvent}
> >
${cache( ${cache(
this._childView this._childView