Comments (2)
Thanks for the report.
Alas, because of the way the v-models (elements, nodes and edges) are setup at the moment I expect that this issue will persist for the remainder of VueFlow 1.
I will address this problem with the next major update - for now you can use onPaneReady
if you need to add some nodes after the initial ones, though be aware that fit-view-on-init
will not play nicely with this and won't consider nodes that have been added after that. You can always call fitView
yourself though, so that's not a big problem :)
A little bit of background on why this happens:
Currently when elements are passed to VueFlow they are "transformed" from Node
-> GraphNode
/ Edge
-> GraphEdge
, adding some additional pieces of info to these elements that are necessary for VueFlow to work correctly.
To allow for direct mutation of these objects like node.position.x = 100
without having to pass a new array of elements, the transformed elements are pushed into your model ref.
So basically what happens is this
- You pass VueFlow your elements ref
- The elements get transformed
- Transformed elements overwrite your elements ref value
To avoid having infinite loops happening while this is done, a pausable watcher is used that waits until your elements ref is overwritten to continue watching for changes.
When you doelements.value.push(...)
duringonMounted
it ends up happening during the pause of this watcher so the new element is never noticed and consumed by VueFlow :/
What does work is onMounted(() => setTimeout(() => {}, 0))
but obviously this isn't a great pattern to use.
In the next major version I'll see that this binding is solved differently since the current implementation has been giving me headaches for too long but re-doing it would be a breaking change since the whole "transformation" needs to stop and be replaced with an internal map that contains these additional pieces of information that VueFlow needs.
Anyway - sorry that I can't give you a better solution at this point in time.
I'll keep this issue open though.
from vue-flow.
@bcakmakoglu Thanks a lot for the detailed explanation and the workarounds.
from vue-flow.
Related Issues (20)
- 🐛 [BUG]: Devtool throws warning when using node resizer HOT 2
- 🐛 [BUG]: `pathOptions` for default edges aren't applied HOT 1
- 🐛 [BUG]: flickering on some phone browsers HOT 4
- 🐛 [BUG]: Wrong edge position with dynamic handle id HOT 5
- 🐛 [BUG]: When typing, CMD + Backspace or Shift + Backspace can delete selected element HOT 1
- 🐛 [BUG]: Docs (vueflow.dev) hangs and never loads on iOS Safari HOT 2
- 🐛 [BUG]: Auto-generated Handle ids change with position HOT 1
- 🐛 [BUG]: <title> manual control <Handle /> graph line confusion HOT 1
- 🐛 [BUG]: manual control <Handle /> graph line confusion HOT 2
- 🐛 [BUG]: `autoPanOnConnect` does not disable panning during connections HOT 1
- Feature Request: Support for Multiple Handles on Nodes HOT 5
- 🐛 [BUG]: Wrong useVueFlow context within pinia HOT 2
- 🐛 [BUG]: PanelPositionType not exported HOT 1
- 🐛 [BUG]: `useHandleConnections` does not call `onConnect` and `onDisconnect` HOT 4
- onConnect method in useHandleConnections still not work after update to version 1.34.1 HOT 2
- 🐛 [BUG]: Hiding/Unhiding Nodes/Edges can be expensive and block the main thread HOT 1
- onDisconnect method in useHandleConnections does not work in useHandleConnections if handle id is specified. HOT 8
- 🐛 [BUG]: node change events not triggered when removing nodes HOT 5
- 🐛 [BUG]: Edge arrow is changing its target/source HOT 4
- 🐛 [BUG]: onConnect sourceHandle/targetHandle is null HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-flow.