From f4bde903028d07105b65d3aa8b95b88562349755 Mon Sep 17 00:00:00 2001 From: Braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 5 Sep 2024 22:12:51 +0200 Subject: [PATCH] fix(core): prevent overwriting size in node styles object (#1608) * fix(core): prevent overwriting size in node styles object Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> * fix(core): update node styles if `updateStyles` is `true` Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> * chore(core): update pkg json links Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> * chore(changeset): add Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --------- Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com> --- .changeset/nice-seals-tickle.md | 6 ++++++ packages/core/package.json | 5 +++-- packages/core/src/components/Nodes/NodeWrapper.ts | 4 ++-- packages/core/src/utils/changes.ts | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 .changeset/nice-seals-tickle.md diff --git a/.changeset/nice-seals-tickle.md b/.changeset/nice-seals-tickle.md new file mode 100644 index 00000000..ce16f1b4 --- /dev/null +++ b/.changeset/nice-seals-tickle.md @@ -0,0 +1,6 @@ +--- +"@vue-flow/core": patch +--- + +Prevent overwriting width/height in node styles object with `node.width`/`node.height` if `width`/`height` already exist in the styles object. +Fixes NodeResizer not working when initial size was passed to a node through `node.width`/`node.height`. diff --git a/packages/core/package.json b/packages/core/package.json index 9f1dbd61..c009ac8e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -6,9 +6,10 @@ "author": "Burak Cakmakoglu<78412429+bcakmakoglu@users.noreply.github.com>", "repository": { "type": "git", - "url": "git+https://github.com/bcakmakoglu/vue-flow" + "url": "git+https://github.com/bcakmakoglu/vue-flow", + "directory": "packages/core" }, - "homepage": "https://github.com/bcakmakoglu/vue-flow#readme", + "homepage": "https://vueflow.dev", "bugs": { "url": "https://github.com/bcakmakoglu/vue-flow/issues" }, diff --git a/packages/core/src/components/Nodes/NodeWrapper.ts b/packages/core/src/components/Nodes/NodeWrapper.ts index 9c443ea4..ba850a10 100644 --- a/packages/core/src/components/Nodes/NodeWrapper.ts +++ b/packages/core/src/components/Nodes/NodeWrapper.ts @@ -142,11 +142,11 @@ const NodeWrapper = defineComponent({ const width = node.width instanceof Function ? node.width(node) : node.width const height = node.height instanceof Function ? node.height(node) : node.height - if (width) { + if (!styles.width && width) { styles.width = typeof width === 'string' ? width : `${width}px` } - if (height) { + if (!styles.height && height) { styles.height = typeof height === 'string' ? height : `${height}px` } diff --git a/packages/core/src/utils/changes.ts b/packages/core/src/utils/changes.ts index f2c01b7f..a3cd9562 100644 --- a/packages/core/src/utils/changes.ts +++ b/packages/core/src/utils/changes.ts @@ -166,7 +166,7 @@ export function applyChanges< element.dimensions = currentChange.dimensions } - if (typeof currentChange.updateStyle !== 'undefined') { + if (typeof currentChange.updateStyle !== 'undefined' && currentChange.updateStyle) { element.style = { ...(element.style || {}), width: `${currentChange.dimensions?.width}px`,