Allow to open more info using query params (#25733)

This commit is contained in:
Paul Bottein 2025-06-10 12:20:10 +02:00 committed by GitHub
parent 6e7ac6fdf7
commit 0474a24df6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -57,6 +57,7 @@ import {
showAlertDialog, showAlertDialog,
showConfirmationDialog, showConfirmationDialog,
} from "../../dialogs/generic/show-dialog-box"; } from "../../dialogs/generic/show-dialog-box";
import { showMoreInfoDialog } from "../../dialogs/more-info/show-ha-more-info-dialog";
import { import {
QuickBarMode, QuickBarMode,
showQuickBar, showQuickBar,
@ -75,9 +76,9 @@ import { getLovelaceStrategy } from "./strategies/get-strategy";
import { isLegacyStrategyConfig } from "./strategies/legacy-strategy"; import { isLegacyStrategyConfig } from "./strategies/legacy-strategy";
import type { Lovelace } from "./types"; import type { Lovelace } from "./types";
import "./views/hui-view"; import "./views/hui-view";
import "./views/hui-view-container";
import type { HUIView } from "./views/hui-view"; import type { HUIView } from "./views/hui-view";
import "./views/hui-view-background"; import "./views/hui-view-background";
import "./views/hui-view-container";
@customElement("hui-root") @customElement("hui-root")
class HUIRoot extends LitElement { class HUIRoot extends LitElement {
@ -490,7 +491,16 @@ class HUIRoot extends LitElement {
} else if (searchParams.conversation === "1") { } else if (searchParams.conversation === "1") {
this._clearParam("conversation"); this._clearParam("conversation");
this._showVoiceCommandDialog(); this._showVoiceCommandDialog();
} else if (searchParams["more-info-entity-id"]) {
const entityId = searchParams["more-info-entity-id"];
this._clearParam("more-info-entity-id");
// Wait for the next render to ensure the view is fully loaded
// because the more info dialog is closed when the url changes
afterNextRender(() => {
this._showMoreInfoDialog(entityId);
});
} }
window.addEventListener("scroll", this._handleWindowScroll, { window.addEventListener("scroll", this._handleWindowScroll, {
passive: true, passive: true,
}); });
@ -730,6 +740,10 @@ class HUIRoot extends LitElement {
showVoiceCommandDialog(this, this.hass, { pipeline_id: "last_used" }); showVoiceCommandDialog(this, this.hass, { pipeline_id: "last_used" });
} }
private _showMoreInfoDialog(entityId: string): void {
showMoreInfoDialog(this, { entityId });
}
private _handleEnableEditMode(ev: CustomEvent<RequestSelectedDetail>): void { private _handleEnableEditMode(ev: CustomEvent<RequestSelectedDetail>): void {
if (!shouldHandleRequestSelectedEvent(ev)) { if (!shouldHandleRequestSelectedEvent(ev)) {
return; return;