Skip to content

Commit 9386e27

Browse files
authored
Merge pull request #339 from pathsim/fix/port-label-refresh
Refresh canvas nodes when a port is renamed
2 parents ad40fb3 + 6523017 commit 9386e27

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/lib/components/FlowCanvas.svelte‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import { createEdgeHighlighter } from '$lib/stores/edgeHighlight';
4747
import { CANVAS_MIN_ZOOM } from '$lib/constants/layout';
4848
import { shallowEqualArray, shallowEqualRecord } from '$lib/utils/shallowEqual';
49-
import type { NodeInstance, Connection, Annotation } from '$lib/nodes/types';
49+
import type { NodeInstance, Connection, Annotation, PortInstance } from '$lib/nodes/types';
5050
import type { EventInstance } from '$lib/events/types';
5151
5252
// Canvas utilities
@@ -151,6 +151,10 @@
151151
// Track port counts to detect changes - used to force node re-renders
152152
let portCounts = new Map<string, { inputs: number; outputs: number }>();
153153
154+
/** Port names by position; Interface ports are derived anew on every read, so references can't be compared */
155+
const samePortNames = (a: PortInstance[], b: PortInstance[]) =>
156+
a.length === b.length && a.every((port, i) => port.name === b[i].name);
157+
154158
// Track nodes that need internal updates (will be processed by FlowUpdater)
155159
let pendingNodeUpdates: string[] = $state([]);
156160
@@ -455,6 +459,7 @@
455459
}
456460
if (currentData.name !== gn.name) return true;
457461
if (currentData.color !== gn.color) return true;
462+
if (!samePortNames(currentData.inputs, gn.inputs) || !samePortNames(currentData.outputs, gn.outputs)) return true;
458463
if (!shallowEqualRecord(currentData.params, gn.params)) return true;
459464
if (!shallowEqualArray(currentData.pinnedParams, gn.pinnedParams)) return true;
460465
return false;

0 commit comments

Comments
 (0)