@@ -5,7 +5,7 @@ import { HomeAssistant, fireEvent, LovelaceCardEditor, LovelaceConfig } from 'cu
55// eslint-disable-next-line @typescript-eslint/no-unused-vars
66import { customElement , property , state } from 'lit/decorators' ;
77import { repeat } from 'lit/directives/repeat' ;
8- import { SankeyChartConfig , Section , SectionConfig , Node } from '../types' ;
8+ import { SankeyChartConfig , Section , SectionConfig , Node , NodeConfigForEditor } from '../types' ;
99import { localize } from '../localize/localize' ;
1010import { normalizeConfig , convertNodesToSections } from '../utils' ;
1111import './section' ;
@@ -162,8 +162,14 @@ export class SankeyChartEditor extends LitElement implements LovelaceCardEditor
162162 const updatedNodes = [ ...nodes ] ;
163163 const existingNode = updatedNodes [ nodeIndex ] ;
164164
165+ // children is a UI-only property in v4 — connections live in links[].
166+ // Strip it from both the incoming conf and the existing node so it never
167+ // gets persisted onto the node.
168+ const { children : newChildren , ...newConfWithoutChildren } = newConf ;
169+ const { children : _existingChildren , ...existingNodeWithoutChildren } = existingNode as NodeConfigForEditor ;
170+
165171 // Merge changes
166- updatedNodes [ nodeIndex ] = { ...existingNode , ...newConf } ;
172+ updatedNodes [ nodeIndex ] = { ...existingNodeWithoutChildren , ...newConfWithoutChildren } ;
167173
168174 // Handle children sync to links
169175 let updatedLinks = this . _config ! . links || [ ] ;
@@ -172,7 +178,7 @@ export class SankeyChartEditor extends LitElement implements LovelaceCardEditor
172178 updatedLinks = updatedLinks . filter ( l => l . source !== nodeId ) ;
173179
174180 // Add new links from children
175- ( newConf . children || [ ] ) . forEach ( child => {
181+ ( newChildren || [ ] ) . forEach ( child => {
176182 const childConf = typeof child === 'string'
177183 ? { entity_id : child }
178184 : child ;
0 commit comments