Commit 5e1aa23
committed
fix(workflow): stop a nested block jumping when it leaves its container
`getNodeAbsolutePosition` added the container's header and padding to a child's
position. Those are already in the position: React Flow places a child at its
parent's origin plus its own coordinates, and `clampPositionToContainer` is what
holds it clear of the chrome, flooring it at `LEFT_PADDING` and
`HEADER_HEIGHT + TOP_PADDING`. Counting them twice put every nested node 16px
right and 66px below where it actually renders.
Visible as a block dropping down-right the moment it is dragged out of a Loop,
and as a block landing off-target when dragged into one from the canvas. Also
skewed container hit-testing during a drag and the bounds `fitView` focuses on.
Two callers already knew: both subtracted the same three constants straight back
off to recover a relative position. They now take the difference of two
absolutes, which is what a relative position is. A third place, React Flow's
child `extent`, had its own copy of the numbers — a fourth distinct header
height, 42, against the 40 the card renders — and now reads the same constants
as the clamp, so a drag stops where a drop would put it.
`positionAbsolute ?? getNodeAbsolutePosition(...)` in the fit-view path can also
stop disagreeing with itself: React Flow's own answer carries no offset, so the
two branches returned points 66px apart for the same node.1 parent 128054e commit 5e1aa23
3 files changed
Lines changed: 129 additions & 26 deletions
File tree
- apps/sim/app/workspace/[workspaceId]/w/[workflowId]
- hooks
Lines changed: 95 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
Lines changed: 16 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
145 | 157 | | |
146 | 158 | | |
147 | 159 | | |
| |||
184 | 196 | | |
185 | 197 | | |
186 | 198 | | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | 199 | | |
192 | | - | |
193 | | - | |
| 200 | + | |
| 201 | + | |
194 | 202 | | |
195 | 203 | | |
196 | 204 | | |
| |||
Lines changed: 18 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
969 | 969 | | |
970 | 970 | | |
971 | 971 | | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
972 | 975 | | |
973 | 976 | | |
974 | | - | |
975 | | - | |
976 | | - | |
977 | 977 | | |
978 | | - | |
979 | | - | |
| 978 | + | |
| 979 | + | |
980 | 980 | | |
981 | 981 | | |
982 | 982 | | |
| |||
2711 | 2711 | | |
2712 | 2712 | | |
2713 | 2713 | | |
2714 | | - | |
2715 | | - | |
2716 | | - | |
2717 | | - | |
2718 | | - | |
2719 | | - | |
| 2714 | + | |
| 2715 | + | |
| 2716 | + | |
| 2717 | + | |
| 2718 | + | |
| 2719 | + | |
| 2720 | + | |
2720 | 2721 | | |
2721 | 2722 | | |
2722 | 2723 | | |
| |||
3767 | 3768 | | |
3768 | 3769 | | |
3769 | 3770 | | |
3770 | | - | |
3771 | | - | |
| 3771 | + | |
| 3772 | + | |
| 3773 | + | |
| 3774 | + | |
3772 | 3775 | | |
3773 | 3776 | | |
3774 | | - | |
3775 | | - | |
3776 | | - | |
3777 | 3777 | | |
3778 | 3778 | | |
3779 | | - | |
3780 | | - | |
| 3779 | + | |
| 3780 | + | |
3781 | 3781 | | |
3782 | 3782 | | |
3783 | 3783 | | |
| |||
0 commit comments