Skip to content

Commit 740cf35

Browse files
committed
fix: remove children from the editor
1 parent fe4a5da commit 740cf35

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/editor/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { HomeAssistant, fireEvent, LovelaceCardEditor, LovelaceConfig } from 'cu
55
// eslint-disable-next-line @typescript-eslint/no-unused-vars
66
import { customElement, property, state } from 'lit/decorators';
77
import { repeat } from 'lit/directives/repeat';
8-
import { SankeyChartConfig, Section, SectionConfig, Node } from '../types';
8+
import { SankeyChartConfig, Section, SectionConfig, Node, NodeConfigForEditor } from '../types';
99
import { localize } from '../localize/localize';
1010
import { normalizeConfig, convertNodesToSections } from '../utils';
1111
import './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

Comments
 (0)