diff --git a/src/panels/config/automation/action/ha-automation-action-row.ts b/src/panels/config/automation/action/ha-automation-action-row.ts index 9aef97719b..4433892287 100644 --- a/src/panels/config/automation/action/ha-automation-action-row.ts +++ b/src/panels/config/automation/action/ha-automation-action-row.ts @@ -145,6 +145,8 @@ export default class HaAutomationActionRow extends LitElement { @property({ type: Boolean }) public disabled = false; + @property({ type: Boolean }) public root = false; + @property({ type: Boolean }) public first?: boolean; @property({ type: Boolean }) public last?: boolean; @@ -178,13 +180,21 @@ export default class HaAutomationActionRow extends LitElement { @state() private _selected = false; - @state() private _collapsed = false; + @state() private _collapsed = true; @state() private _warnings?: string[]; @query("ha-automation-action-editor") private _actionEditor?: HaAutomationActionEditor; + protected firstUpdated(changedProperties: PropertyValues): void { + super.firstUpdated(changedProperties); + + if (this.root) { + this._collapsed = false; + } + } + protected willUpdate(changedProperties: PropertyValues) { if (changedProperties.has("yamlMode")) { this._warnings = undefined; diff --git a/src/panels/config/automation/action/ha-automation-action.ts b/src/panels/config/automation/action/ha-automation-action.ts index 0d7116ce93..193d2519dd 100644 --- a/src/panels/config/automation/action/ha-automation-action.ts +++ b/src/panels/config/automation/action/ha-automation-action.ts @@ -95,6 +95,7 @@ export default class HaAutomationAction extends LitElement { (action) => this._getKey(action), (action, idx) => html` clear warnings if (changedProperties.has("yamlMode")) { diff --git a/src/panels/config/automation/condition/ha-automation-condition.ts b/src/panels/config/automation/condition/ha-automation-condition.ts index 2ed3cdf401..50c14d6117 100644 --- a/src/panels/config/automation/condition/ha-automation-condition.ts +++ b/src/panels/config/automation/condition/ha-automation-condition.ts @@ -117,9 +117,8 @@ export default class HaAutomationCondition extends LitElement { behavior: "smooth", }); } - } else if (!this.optionsInSidebar) { - row.expand(); } + row.expand(); row.focus(); }); } @@ -158,6 +157,7 @@ export default class HaAutomationCondition extends LitElement { (condition) => this._getKey(condition), (cond, idx) => html` ) { // deselect previous selected row this._sidebarConfig?.close?.(); diff --git a/src/panels/config/automation/option/ha-automation-option-row.ts b/src/panels/config/automation/option/ha-automation-option-row.ts index 0be8c91368..438c6f52a2 100644 --- a/src/panels/config/automation/option/ha-automation-option-row.ts +++ b/src/panels/config/automation/option/ha-automation-option-row.ts @@ -65,7 +65,7 @@ export default class HaAutomationOptionRow extends LitElement { @state() private _selected = false; - @state() private _collapsed = false; + @state() private _collapsed = true; @state() @consume({ context: fullEntitiesContext, subscribe: true }) diff --git a/src/panels/config/automation/option/ha-automation-option.ts b/src/panels/config/automation/option/ha-automation-option.ts index 38e7a96ac1..f989000301 100644 --- a/src/panels/config/automation/option/ha-automation-option.ts +++ b/src/panels/config/automation/option/ha-automation-option.ts @@ -133,14 +133,13 @@ export default class HaAutomationOption extends LitElement { "ha-automation-option-row:last-of-type" )!; row.updateComplete.then(() => { - if (!this.optionsInSidebar) { - row.expand(); - } else if (this.narrow) { + if (this.narrow) { row.scrollIntoView({ block: "start", behavior: "smooth", }); } + row.expand(); row.focus(); }); } diff --git a/src/panels/config/script/manual-script-editor.ts b/src/panels/config/script/manual-script-editor.ts index 52df2fd0c8..1f610a9807 100644 --- a/src/panels/config/script/manual-script-editor.ts +++ b/src/panels/config/script/manual-script-editor.ts @@ -1,6 +1,6 @@ import { mdiContentSave, mdiHelpCircle } from "@mdi/js"; import { load } from "js-yaml"; -import type { CSSResultGroup } from "lit"; +import type { CSSResultGroup, PropertyValues } from "lit"; import { css, html, LitElement, nothing } from "lit"; import { customElement, property, query, state } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; @@ -17,6 +17,11 @@ import { import { ensureArray } from "../../../common/array/ensure-array"; import { canOverrideAlphanumericInput } from "../../../common/dom/can-override-input"; import { fireEvent } from "../../../common/dom/fire_event"; +import { constructUrlCurrentPath } from "../../../common/url/construct-url"; +import { + extractSearchParam, + removeSearchParam, +} from "../../../common/url/search-params"; import { computeRTL } from "../../../common/util/compute_rtl"; import "../../../components/ha-icon-button"; import "../../../components/ha-markdown"; @@ -221,6 +226,23 @@ export class HaManualScriptEditor extends LitElement { `; } + protected firstUpdated(changedProps: PropertyValues): void { + super.firstUpdated(changedProps); + const expanded = extractSearchParam("expanded"); + if (expanded === "1") { + this._clearParam("expanded"); + this.expandAll(); + } + } + + private _clearParam(param: string) { + window.history.replaceState( + null, + "", + constructUrlCurrentPath(removeSearchParam(param)) + ); + } + private _fieldsChanged(ev: CustomEvent): void { ev.stopPropagation(); this.resetPastedConfig();