diff --git a/packages/core/src/store/actions.ts b/packages/core/src/store/actions.ts index 95529da3..0d0b4fa8 100644 --- a/packages/core/src/store/actions.ts +++ b/packages/core/src/store/actions.ts @@ -38,6 +38,10 @@ export function useActions( } const findNode: Actions['findNode'] = (id) => { + if (!id) { + return + } + if (state.nodes && !nodeIds.value.length) { return state.nodes.find((node) => node.id === id) } @@ -46,6 +50,10 @@ export function useActions( } const findEdge: Actions['findEdge'] = (id) => { + if (!id) { + return + } + if (state.edges && !edgeIds.value.length) { return state.edges.find((edge) => edge.id === id) } diff --git a/packages/core/src/types/store.ts b/packages/core/src/types/store.ts index 6523317a..2a363f73 100644 --- a/packages/core/src/types/store.ts +++ b/packages/core/src/types/store.ts @@ -179,11 +179,11 @@ export type UpdateNodeDimensions = (updates: UpdateNodeDimensionsParams[]) => vo export type UpdateNodeInternals = (nodeIds?: string[]) => void export type FindNode = = any>( - id: string, + id: string | undefined, ) => GraphNode | undefined export type FindEdge = = any>( - id: string, + id: string | undefined, ) => GraphEdge | undefined export type GetIntersectingNodes = (