Skip to content

Commit f4bde90

Browse files
committed
fix(core): prevent overwriting size in node styles object (#1608)
* fix(core): prevent overwriting size in node styles object Signed-off-by: braks <[email protected]> * fix(core): update node styles if `updateStyles` is `true` Signed-off-by: braks <[email protected]> * chore(core): update pkg json links Signed-off-by: braks <[email protected]> * chore(changeset): add Signed-off-by: braks <[email protected]> --------- Signed-off-by: braks <[email protected]>
1 parent 79fb61c commit f4bde90

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

.changeset/nice-seals-tickle.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@vue-flow/core": patch
3+
---
4+
5+
Prevent overwriting width/height in node styles object with `node.width`/`node.height` if `width`/`height` already exist in the styles object.
6+
Fixes NodeResizer not working when initial size was passed to a node through `node.width`/`node.height`.

packages/core/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
"author": "Burak Cakmakoglu<[email protected]>",
77
"repository": {
88
"type": "git",
9-
"url": "git+https://github.com/bcakmakoglu/vue-flow"
9+
"url": "git+https://github.com/bcakmakoglu/vue-flow",
10+
"directory": "packages/core"
1011
},
11-
"homepage": "https://github.com/bcakmakoglu/vue-flow#readme",
12+
"homepage": "https://vueflow.dev",
1213
"bugs": {
1314
"url": "https://github.com/bcakmakoglu/vue-flow/issues"
1415
},

packages/core/src/components/Nodes/NodeWrapper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ const NodeWrapper = defineComponent({
142142
const width = node.width instanceof Function ? node.width(node) : node.width
143143
const height = node.height instanceof Function ? node.height(node) : node.height
144144

145-
if (width) {
145+
if (!styles.width && width) {
146146
styles.width = typeof width === 'string' ? width : `${width}px`
147147
}
148148

149-
if (height) {
149+
if (!styles.height && height) {
150150
styles.height = typeof height === 'string' ? height : `${height}px`
151151
}
152152

packages/core/src/utils/changes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export function applyChanges<
166166
element.dimensions = currentChange.dimensions
167167
}
168168

169-
if (typeof currentChange.updateStyle !== 'undefined') {
169+
if (typeof currentChange.updateStyle !== 'undefined' && currentChange.updateStyle) {
170170
element.style = {
171171
...(element.style || {}),
172172
width: `${currentChange.dimensions?.width}px`,

0 commit comments

Comments
 (0)