From e41a66dc2d3a713288ffc0e67674e7ae7002aff4 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 20 Apr 2023 10:33:42 +0200 Subject: [PATCH] fix(core): set default edge opts before setting elements Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --- packages/core/src/store/actions.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/core/src/store/actions.ts b/packages/core/src/store/actions.ts index 29be14a2..9a59c2fd 100644 --- a/packages/core/src/store/actions.ts +++ b/packages/core/src/store/actions.ts @@ -661,8 +661,14 @@ export function useActions( 'translateExtent', 'nodeExtent', 'hooks', + 'defaultEdgeOptions', ] + // we need to set the default opts before setting any elements so the options are applied to the elements on first render + if (isDef(opts.defaultEdgeOptions)) { + state.defaultEdgeOptions = opts.defaultEdgeOptions + } + const elements = opts.modelValue || opts.nodes || opts.edges ? ([] as Elements) : undefined if (elements) { @@ -682,16 +688,16 @@ export function useActions( } const setSkippedOptions = () => { - if (typeof opts.maxZoom !== 'undefined') { + if (isDef(opts.maxZoom)) { setMaxZoom(opts.maxZoom) } - if (typeof opts.minZoom !== 'undefined') { + if (isDef(opts.minZoom)) { setMinZoom(opts.minZoom) } - if (typeof opts.translateExtent !== 'undefined') { + if (isDef(opts.translateExtent)) { setTranslateExtent(opts.translateExtent) } - if (typeof opts.nodeExtent !== 'undefined') { + if (isDef(opts.nodeExtent)) { setNodeExtent(opts.nodeExtent) } }