b310-digital / teammapper

Mindmapping made simple: Host and create your own mindmaps. Share your mindmap sessions with your team and collaborate on mindmaps.
https://teammapper.org
MIT License
203 stars 16 forks source link

Detached nodes after creation at different positions #250

Open JannikStreek opened 5 months ago

JannikStreek commented 5 months ago

Describe the bug When a detached node is created, the position seems to be different on clients.

To Reproduce Steps to reproduce the behavior:

  1. Add a detached node
  2. Compare position with different joined clients
  3. After moving the node, positions are synced properly

Expected behavior Position should be the same, even in the beginning.

Screenshots

sorenjohanson commented 2 days ago

Core issue seems to be this:

When a new detached node is created (for example based off of the root node), it's coordinates are set to 0,0 (x,y) in mmp.service.ts#221. The same method then calls addNode, which adds -80 to y coordinates at nodes.ts#620, presumably to prevent overlap. This is all done client-side. At this point, the node is saved server side with the coordinates 0,-80 and the other client receives it. However, the other client calls the same method at nodes.ts#620 and adds another -80 to y coordinates (again, to prevent overlap), causing the coordinates to be 0,-160 instead of 0,-80.