Skip to content

Commit cff55c8

Browse files
committed
refactor(core): use empty arr when updating all internals (#1476)
* refactor(core): use empty arr when updating all internals * chore(changeset): add
1 parent 55a76cd commit cff55c8

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

.changeset/silver-plums-relate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-flow/core": minor
3+
---
4+
5+
Use empty array when determing whether to update all node internals

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ const NodeWrapper = defineComponent({
153153
const zIndex = toRef(() => Number(node.zIndex ?? getStyle.value.zIndex ?? 0))
154154

155155
onUpdateNodeInternals((updateIds) => {
156-
if (updateIds.includes(props.id)) {
156+
// when no ids are passed, update all nodes
157+
if (updateIds.includes(props.id) || !updateIds.length) {
157158
updateInternals()
158159
}
159160
})

packages/core/src/composables/useViewportHelper.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const initialViewportHelper: ViewportHelper = {
3939
*
4040
* @internal
4141
* @param state
42-
* @param getters
4342
*/
4443
export function useViewportHelper(state: State) {
4544
function zoom(scale: number, duration?: number) {

packages/core/src/store/actions.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,11 @@ import {
5353
} from '../utils'
5454
import { storeOptionsToSkip, useState } from './state'
5555

56-
export function useActions(
57-
id: string,
58-
state: State,
59-
nodeLookup: ComputedRef<NodeLookup>,
60-
edgeLookup: ComputedRef<EdgeLookup>,
61-
): Actions {
56+
export function useActions(state: State, nodeLookup: ComputedRef<NodeLookup>, edgeLookup: ComputedRef<EdgeLookup>): Actions {
6257
const viewportHelper = useViewportHelper(state)
6358

6459
const updateNodeInternals: Actions['updateNodeInternals'] = (ids) => {
65-
const updateIds = ids ?? state.nodes.map((n) => n.id) ?? []
60+
const updateIds = ids ?? []
6661

6762
state.hooks.updateNodeInternals.trigger(updateIds)
6863
}

packages/core/src/utils/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class Storage {
7878

7979
const getters = useGetters(reactiveState, nodeLookup, edgeLookup)
8080

81-
const actions = useActions(id, reactiveState, nodeLookup, edgeLookup)
81+
const actions = useActions(reactiveState, nodeLookup, edgeLookup)
8282

8383
actions.setState({ ...reactiveState, ...preloadedState })
8484

0 commit comments

Comments
 (0)