Buggy positioning behaviour, after using frame.add() in Web SDK v2

  • 29 December 2022
  • 3 replies
  • 38 views

Badge +1

Hi there,

I’m currently  trying  to migrate the Field plugin to Web SDK v2 and having trouble to position Sticky Notes in a Frame once I have added the Sticky Note as a Child using the frame->add() method.

I have created a simple example on a freshly created Board to demonstrate the unexpected behavior. I recorded a little loom video. Please have a look at what I am doing in the web developer toolbar. It’s wired, that the Sticky Note is displayed outside the frame. I would love to get some help here: What am I missing? Team Miro - can someone please point me to a working example, where a Sticky Note is first added to a frame, and then positioned inside the frame?
Thanks in advance!

 


3 replies

Badge +1

 I’d better add what I have done to demonstrate the behavior (visible at 2:40 in the video).

// in web developer toolbar

// manually create a frame, select the frame
ff = (await miro.board.getSelection())[0];

// position the frame at the origin of the board
ff.x=0; ff.y=0; ff.sync();

// manually create a sticky note outside of the frame, select the sticky note
sn = (await miro.board.getSelection())[0]
sn.parentId; // is null

// position the sticky note at the origin of the board
sn.x=0; sn.y=0; sn.sync();

// => visisble on top of the frame

// add sticky not as child to frame
ff.add(sn);
ff.sync();

// => now coordinates should be relative to top left of the frame?
// try to move sticky note
sn.x = 100; sn.y = 0; sn.sync();

// => weired position outside of frame

https://gist.github.com/rockitbaby/475e732d14c06c080cacbac9a73804c1

 

Userlevel 5
Badge +3

Hi @Michael Schieben,

Thank you very much for raising this and for sharing the detailed video/snippet. Indeed, this is not the intended behavior when working with relative coordinates of a child item within a parent. 

As it turns out, if you refresh the page after you update the position of the child item, you will likely see it in the expected position.

I’ve raised this as a bug with our Web SDK team, and we’re working on a solution.

I’ll follow up here as soon as this is fixed. Thanks again!
Will

Userlevel 5
Badge +3

Hi @Michael Schieben,

Our team released a fix today that we believe should resolve this issue. Can you let me know if you’re still seeing this issue?

Thanks!
Will

Reply