From d64ade38480c3bf4e10bff3bb53c6ea15104b0dc Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 24 Aug 2022 09:58:29 -0400 Subject: [PATCH] Scroll to new added trigger/condition/row (#13473) --- .../config/automation/action/ha-automation-action.ts | 8 ++++++-- .../automation/condition/ha-automation-condition.ts | 8 ++++++-- .../config/automation/trigger/ha-automation-trigger.ts | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/panels/config/automation/action/ha-automation-action.ts b/src/panels/config/automation/action/ha-automation-action.ts index b34d814cdf..9c65fa1fba 100644 --- a/src/panels/config/automation/action/ha-automation-action.ts +++ b/src/panels/config/automation/action/ha-automation-action.ts @@ -92,8 +92,11 @@ export default class HaAutomationAction extends LitElement { const row = this.shadowRoot!.querySelector( "ha-automation-action-row:last-of-type" )!; - row.expand(); - row.focus(); + row.updateComplete.then(() => { + row.expand(); + row.scrollIntoView(); + row.focus(); + }); } } @@ -178,6 +181,7 @@ export default class HaAutomationAction extends LitElement { ha-automation-action-row { display: block; margin-bottom: 16px; + scroll-margin-top: 48px; } ha-svg-icon { height: 20px; diff --git a/src/panels/config/automation/condition/ha-automation-condition.ts b/src/panels/config/automation/condition/ha-automation-condition.ts index 52ce971bbc..67233bbfe2 100644 --- a/src/panels/config/automation/condition/ha-automation-condition.ts +++ b/src/panels/config/automation/condition/ha-automation-condition.ts @@ -69,8 +69,11 @@ export default class HaAutomationCondition extends LitElement { const row = this.shadowRoot!.querySelector( "ha-automation-condition-row:last-of-type" )!; - row.expand(); - row.focus(); + row.updateComplete.then(() => { + row.expand(); + row.scrollIntoView(); + row.focus(); + }); } } @@ -187,6 +190,7 @@ export default class HaAutomationCondition extends LitElement { ha-automation-condition-row { display: block; margin-bottom: 16px; + scroll-margin-top: 48px; } ha-svg-icon { height: 20px; diff --git a/src/panels/config/automation/trigger/ha-automation-trigger.ts b/src/panels/config/automation/trigger/ha-automation-trigger.ts index 7ba92d87c2..3a9b936f53 100644 --- a/src/panels/config/automation/trigger/ha-automation-trigger.ts +++ b/src/panels/config/automation/trigger/ha-automation-trigger.ts @@ -88,8 +88,11 @@ export default class HaAutomationTrigger extends LitElement { const row = this.shadowRoot!.querySelector( "ha-automation-trigger-row:last-of-type" )!; - row.expand(); - row.focus(); + row.updateComplete.then(() => { + row.expand(); + row.scrollIntoView(); + row.focus(); + }); } } @@ -167,6 +170,7 @@ export default class HaAutomationTrigger extends LitElement { ha-automation-trigger-row { display: block; margin-bottom: 16px; + scroll-margin-top: 48px; } ha-svg-icon { height: 20px;