diff --git a/src/components/trace/hat-script-graph.ts b/src/components/trace/hat-script-graph.ts index 41d0ae51e9..0247bbc8f0 100644 --- a/src/components/trace/hat-script-graph.ts +++ b/src/components/trace/hat-script-graph.ts @@ -597,28 +597,30 @@ export class HatScriptGraph extends LitElement { : undefined; try { return html` -
- ${triggerNodes - ? html` - ${triggerNodes} - ` - : ""} - ${conditionKey in this.trace.config - ? html`${ensureArray(this.trace.config[conditionKey])?.map( - (condition, i) => this._renderCondition(condition, i) - )}` - : ""} - ${actionKey in this.trace.config - ? html`${ensureArray(this.trace.config[actionKey]).map( - (action, i) => this._renderActionNode(action, `action/${i}`) - )}` - : ""} - ${"sequence" in this.trace.config - ? html`${ensureArray(this.trace.config.sequence).map( - (action, i) => - this._renderActionNode(action, `sequence/${i}`, i === 0) - )}` - : ""} +
+
+ ${triggerNodes + ? html` + ${triggerNodes} + ` + : ""} + ${conditionKey in this.trace.config + ? html`${ensureArray(this.trace.config[conditionKey])?.map( + (condition, i) => this._renderCondition(condition, i) + )}` + : ""} + ${actionKey in this.trace.config + ? html`${ensureArray(this.trace.config[actionKey]).map( + (action, i) => this._renderActionNode(action, `action/${i}`) + )}` + : ""} + ${"sequence" in this.trace.config + ? html`${ensureArray(this.trace.config.sequence).map( + (action, i) => + this._renderActionNode(action, `sequence/${i}`, i === 0) + )}` + : ""} +
) { super.updated(changedProps); + if (!changedProps.has("trace") && !changedProps.has("selected")) { + return; + } + + // Scroll to active node when selection changes + if (changedProps.has("selected")) { + const activeNode = this.renderRoot.querySelector( + "hat-graph-node[active], hat-graph-branch[active]" + ) as HTMLElement; + if (activeNode) { + activeNode.scrollIntoView({ behavior: "smooth", block: "nearest" }); + } + } + if (!changedProps.has("trace")) { return; } @@ -717,6 +733,8 @@ export class HatScriptGraph extends LitElement { return css` :host { display: flex; + flex-direction: row; + overflow: hidden; --stroke-clr: var(--stroke-color, var(--secondary-text-color)); --active-clr: var(--active-color, var(--primary-color)); --track-clr: var(--track-color, var(--accent-color)); @@ -734,6 +752,11 @@ export class HatScriptGraph extends LitElement { --hat-graph-node-size: ${NODE_SIZE}px; --hat-graph-branch-height: ${BRANCH_HEIGHT}px; } + .graph-scroll { + flex: 1; + overflow: auto; + min-width: 0; + } .graph-container { display: flex; flex-direction: column; diff --git a/src/layouts/hass-subpage.ts b/src/layouts/hass-subpage.ts index 94ef7fd24f..1b8fd76dcd 100644 --- a/src/layouts/hass-subpage.ts +++ b/src/layouts/hass-subpage.ts @@ -23,6 +23,8 @@ class HassSubpage extends LitElement { @property({ type: Boolean, reflect: true }) public narrow = false; + @property({ type: Boolean }) public scrollable = true; + // @ts-ignore @restoreScroll(".content") private _savedScrollPos?: number; @@ -57,7 +59,14 @@ class HassSubpage extends LitElement {
-
+
@@ -163,6 +172,12 @@ class HassSubpage extends LitElement { overflow: auto; -webkit-overflow-scrolling: touch; } + .content.not-scrollable { + overflow: hidden; + display: flex; + flex-direction: column; + } + :host([narrow]) .content { width: calc( 100% - var(--safe-area-inset-left, 0px) - var( diff --git a/src/panels/config/automation/ha-automation-trace.ts b/src/panels/config/automation/ha-automation-trace.ts index 697272dbfd..665def9d6d 100644 --- a/src/panels/config/automation/ha-automation-trace.ts +++ b/src/panels/config/automation/ha-automation-trace.ts @@ -101,7 +101,12 @@ export class HaAutomationTrace extends LitElement { return html` ${devButtons} - + ${!this.narrow && stateObj?.attributes.id ? html` + ${!this.narrow && this.scriptId ? html`