fix: cluster edge type and label now persisted on connect
- canvasStore.onConnect was hardcoding type=ethernet and ignoring edgeData fields (type, label, color, etc.) - EdgeModal had no key, so useState was not reset between connections — initial prop ignored - Added key based on source/target/handles so modal re-mounts for each new connection
This commit is contained in:
@@ -53,10 +53,18 @@ export const useCanvasStore = create<CanvasState>((set) => ({
|
||||
})),
|
||||
|
||||
onConnect: (connection) =>
|
||||
set((state) => ({
|
||||
edges: addEdge({ ...connection, type: 'ethernet', data: { type: 'ethernet' } }, state.edges),
|
||||
hasUnsavedChanges: true,
|
||||
})),
|
||||
set((state) => {
|
||||
const extra = connection as Connection & Partial<EdgeData>
|
||||
const edgeType = extra.type ?? 'ethernet'
|
||||
return {
|
||||
edges: addEdge({
|
||||
...connection,
|
||||
type: edgeType,
|
||||
data: { type: edgeType, label: extra.label, vlan_id: extra.vlan_id, custom_color: extra.custom_color, path_style: extra.path_style },
|
||||
}, state.edges),
|
||||
hasUnsavedChanges: true,
|
||||
}
|
||||
}),
|
||||
|
||||
setSelectedNode: (id) => set({ selectedNodeId: id }),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user