Skip to content

Commit 77735f5

Browse files
authored
Fix automation sidebar editor rerendering (#27607)
1 parent e388756 commit 77735f5

8 files changed

+22
-10
lines changed

src/panels/config/automation/ha-automation-sidebar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ export default class HaAutomationSidebar extends LitElement {
3636

3737
@property({ type: Boolean }) public narrow = false;
3838

39-
@property({ attribute: "sidebar-key" }) public sidebarKey?: string;
39+
@property({ type: Number, attribute: "sidebar-key" })
40+
public sidebarKey?: number;
4041

4142
@state() private _yamlMode = false;
4243

src/panels/config/automation/manual-automation-editor.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class HaManualAutomationEditor extends LitElement {
101101

102102
@state() private _sidebarConfig?: SidebarConfig;
103103

104-
@state() private _sidebarKey?: string;
104+
@state() private _sidebarKey = 0;
105105

106106
@storage({
107107
key: "automation-sidebar-width",
@@ -350,7 +350,9 @@ export class HaManualAutomationEditor extends LitElement {
350350
// deselect previous selected row
351351
this._sidebarConfig?.close?.();
352352
this._sidebarConfig = ev.detail;
353-
this._sidebarKey = JSON.stringify(this._sidebarConfig);
353+
354+
// be sure the sidebar editor is recreated
355+
this._sidebarKey++;
354356

355357
await this._sidebarElement?.updateComplete;
356358
this._sidebarElement?.focus();
@@ -375,6 +377,7 @@ export class HaManualAutomationEditor extends LitElement {
375377
return;
376378
}
377379
this._sidebarConfig?.close();
380+
this._sidebarKey = 0;
378381
}
379382
}
380383

src/panels/config/automation/sidebar/ha-automation-sidebar-action.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export default class HaAutomationSidebarAction extends LitElement {
4444

4545
@property({ type: Boolean }) public narrow = false;
4646

47-
@property({ attribute: "sidebar-key" }) public sidebarKey?: string;
47+
@property({ type: Number, attribute: "sidebar-key" })
48+
public sidebarKey?: number;
4849

4950
@state() private _warnings?: string[];
5051

src/panels/config/automation/sidebar/ha-automation-sidebar-condition.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ export default class HaAutomationSidebarCondition extends LitElement {
4444

4545
@property({ type: Boolean }) public narrow = false;
4646

47-
@property({ attribute: "sidebar-key" }) public sidebarKey?: string;
47+
@property({ type: Number, attribute: "sidebar-key" })
48+
public sidebarKey?: number;
4849

4950
@state() private _warnings?: string[];
5051

src/panels/config/automation/sidebar/ha-automation-sidebar-script-field-selector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export default class HaAutomationSidebarScriptFieldSelector extends LitElement {
2626

2727
@property({ type: Boolean }) public narrow = false;
2828

29-
@property({ attribute: "sidebar-key" }) public sidebarKey?: string;
29+
@property({ type: Number, attribute: "sidebar-key" })
30+
public sidebarKey?: number;
3031

3132
@state() private _warnings?: string[];
3233

src/panels/config/automation/sidebar/ha-automation-sidebar-script-field.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export default class HaAutomationSidebarScriptField extends LitElement {
2525

2626
@property({ type: Boolean }) public narrow = false;
2727

28-
@property({ attribute: "sidebar-key" }) public sidebarKey?: string;
28+
@property({ type: Number, attribute: "sidebar-key" })
29+
public sidebarKey?: number;
2930

3031
@state() private _warnings?: string[];
3132

src/panels/config/automation/sidebar/ha-automation-sidebar-trigger.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export default class HaAutomationSidebarTrigger extends LitElement {
3737

3838
@property({ type: Boolean }) public narrow = false;
3939

40-
@property({ attribute: "sidebar-key" }) public sidebarKey?: string;
40+
@property({ type: Number, attribute: "sidebar-key" })
41+
public sidebarKey?: number;
4142

4243
@state() private _warnings?: string[];
4344

src/panels/config/script/manual-script-editor.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class HaManualScriptEditor extends LitElement {
8989

9090
@state() private _sidebarConfig?: SidebarConfig;
9191

92-
@state() private _sidebarKey?: string;
92+
@state() private _sidebarKey = 0;
9393

9494
@storage({
9595
key: "automation-sidebar-width",
@@ -512,7 +512,9 @@ export class HaManualScriptEditor extends LitElement {
512512
// deselect previous selected row
513513
this._sidebarConfig?.close?.();
514514
this._sidebarConfig = ev.detail;
515-
this._sidebarKey = JSON.stringify(this._sidebarConfig);
515+
516+
// be sure the sidebar editor is recreated
517+
this._sidebarKey++;
516518

517519
await this._sidebarElement?.updateComplete;
518520
this._sidebarElement?.focus();
@@ -537,6 +539,7 @@ export class HaManualScriptEditor extends LitElement {
537539
return;
538540
}
539541
this._sidebarConfig?.close();
542+
this._sidebarKey = 0;
540543
}
541544
}
542545

0 commit comments

Comments
 (0)