Skip to content

fix(#1935): size a loop box from its body's bounds relative to the loop - #1942

Open
engalar wants to merge 1 commit into
mendixlabs:mainfrom
engalar:fix/1935-loop-box-relative-size
Open

engalar wants to merge 1 commit into
mendixlabs:mainfrom
engalar:fix/1935-loop-box-relative-size

Conversation

@engalar

@engalar engalar commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

A loop written by 'create microflow' got its Size from its body's ABSOLUTE
canvas coordinates: moving the loop 600px right grew the box by exactly 600
(body at 600,300 -> 710;380; at 1200,300 -> 1310;380), and the centred box
swallowed its neighbours - MPR008/MPR011 then blamed the neighbourhood.
Rebuilt flows kept the sticky wrong size (#1935).

Root cause: @position is a canvas coordinate everywhere in the language, but
a loop's ObjectCollection stores children relative to the loop's top-left
frame. The builder filed the authored value raw, fitContainerSize measured
those canvas values, and Studio Pro drew the child shifted inside the frame.

One contract, both directions - canvas in the language, frame in storage:

  • builder: addStatement records the consumed canvas @position per built
    object (save/restored across nested dispatches so an IF's branches do not
    wipe the split's); @merge-positioned merges join the canvas family in
    container bodies; the container's finalize translates them into its frame
    once the box size is final, and re-derives enum-split tail sides whose
    creation-time comparison mixed spaces.
  • sizing: fitContainerSizeWithAuthored bounds the box around the loop's own
    anchor (authored centre sized symmetrically, flow-placed loops grow from
    their pinned edge), so the box depends on where the body sits RELATIVE to
    the loop, never on where the loop sits on the canvas.
  • describer: emission adds the frame back on @position/@merge inside loop
    bodies (ExecContext.describeFrameOrigin), keeping describe->exec
    byte-identical for Studio Pro and mxcli-authored flows alike.
  • splice: storedLocator.within, pinBody and storedLoopStatement translate
    the other way, so create or modify keeps addressing loop bodies.

Old scripts' stored loop geometry changes on re-exec - that is the fix:
the sticky wrong box heals on rebuild. Auto-placed bodies (#884) and
explicit @SiZe overrides (#2369) keep their contracts.

Test: mdl/executor/issue1935_loop_box_test.go (box independent of loop
position for loop and while; child stored relative to the frame; the
auto-placed and @SiZe contracts kept). Verified end to end on 11.12.4:
bson dump of the issue's own repro stores 220;360 for both loops and
110;280 for both children, describe->exec reports Unchanged, mx check
and lint stay quiet.

Fixes #1935

… to the loop

A loop written by 'create microflow' got its Size from its body's ABSOLUTE
canvas coordinates: moving the loop 600px right grew the box by exactly 600
(body at 600,300 -> 710;380; at 1200,300 -> 1310;380), and the centred box
swallowed its neighbours - MPR008/MPR011 then blamed the neighbourhood.
Rebuilt flows kept the sticky wrong size (mendixlabs#1935).

Root cause: @position is a canvas coordinate everywhere in the language, but
a loop's ObjectCollection stores children relative to the loop's top-left
frame. The builder filed the authored value raw, fitContainerSize measured
those canvas values, and Studio Pro drew the child shifted inside the frame.

One contract, both directions - canvas in the language, frame in storage:

- builder: addStatement records the consumed canvas @position per built
  object (save/restored across nested dispatches so an IF's branches do not
  wipe the split's); @merge-positioned merges join the canvas family in
  container bodies; the container's finalize translates them into its frame
  once the box size is final, and re-derives enum-split tail sides whose
  creation-time comparison mixed spaces.
- sizing: fitContainerSizeWithAuthored bounds the box around the loop's own
  anchor (authored centre sized symmetrically, flow-placed loops grow from
  their pinned edge), so the box depends on where the body sits RELATIVE to
  the loop, never on where the loop sits on the canvas.
- describer: emission adds the frame back on @position/@merge inside loop
  bodies (ExecContext.describeFrameOrigin), keeping describe->exec
  byte-identical for Studio Pro and mxcli-authored flows alike.
- splice: storedLocator.within, pinBody and storedLoopStatement translate
  the other way, so create or modify keeps addressing loop bodies.

Old scripts' stored loop geometry changes on re-exec - that is the fix:
the sticky wrong box heals on rebuild. Auto-placed bodies (mendixlabs#884) and
explicit @SiZe overrides (#2369) keep their contracts.

Test: mdl/executor/issue1935_loop_box_test.go (box independent of loop
position for loop and while; child stored relative to the frame; the
auto-placed and @SiZe contracts kept). Verified end to end on 11.12.4:
bson dump of the issue's own repro stores 220;360 for both loops and
110;280 for both children, describe->exec reports Unchanged, mx check
and lint stay quiet.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A new loop box is sized from its body's absolute canvas coordinates, so it covers neighbouring activities

2 participants