Repository navigation
Commit 8f41b2d
fix(flow designer): a flow wider than the canvas opens zoomed out to fit its width (#27978)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg4i9JiKjEjwtuVzd4gKy9hB)_
## 维护者速读
- 改了什么:流程画布打开时,如果流程图比画布宽(例如手机宽度下有分支的流程),会先缩小到宽度放得下(最低 40%)并居中;放得下的流程仍按
100% 打开,打开时从不放大。
- 为什么改:HotCRM 浏览器走查(#27356 第 22 行)在手机宽度下看到流程画布按 100% 打开,两侧的分支节点被切掉。
- 风险与回滚:只改画布挂载时的一次缩放计算,不改缩放按钮、适应视图和宽度变化时的重新适配;回滚就是 revert 本 PR。
- 先看:`FlowCanvas.tsx` 里挂载时居中的那个 effect(`#27356 row 22` 注释处)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/previews/FlowCanvas.openFit-27356.test.tsx`,应见
4 passed。
- 需要你做的:无,席位落地。
Part of #27356 (row 22, hotcrm#2320 Studio S11: the flow canvas opens
fitted at phone width)
Clause-②: no
Metadata-protocol: none
## What changes
- **A diagram wider than the canvas opens fitted to its width.**
`FlowCanvas` framed every flow at 100%, centred, on mount. On a
phone-width canvas a branching flow's outer branch nodes hung off both
edges until the author pressed fit-to-view. The mount framing now takes
`z = max(MIN_ZOOM, min(1, (canvasWidth - 32) / diagramWidth))` and
centres the diagram at that zoom.
- It never zooms in: a diagram that fits opens at 100%, as before.
- Width only: a tall linear flow still opens at 1:1, top-aligned, and
the author scrolls down. This keeps the "familiar 1:1 on open" promise
the effect's comment makes for every diagram that fits across.
- A 0-wide (hidden) canvas opens at 100%, the same "nothing to fit"
reading the width-change re-fit (objectui#11795) uses.
- Unchanged: the zoom buttons, fit-to-view, the re-fit on a canvas width
change, and the `addNode` / `insertOnEdge` call sites (another card is
changing those two).
- The surface: `views/metadata-admin/previews/FlowCanvas.tsx` is outside
this order's declared Studio surface; the seat widened it to this one
file for row 22.
## Tests
- New `FlowCanvas.openFit-27356.test.tsx` (4 tests) on the real canvas,
with the viewport's box and `ResizeObserver` doubled as in
`FlowCanvas.resizeFit-11795`: a three-branch flow at 390px opens below
100%, centred, its whole width inside the canvas, and the zoom readout
shows that zoom; the same flow at 1400px opens at 100%, centred; a
linear flow that fits 390px opens at 100%; a 0-wide canvas opens at
100%.
<details><summary>Readings (head 881dbf5, run on bf7e1c77, the same
tree before a message-only amend; branch rebuilt from origin/main
bacb3e6 after #27927 merged; install and app-shell closure
rebuilt)</summary>
- New file: 4/4 passed.
- Every ui test file naming `FlowCanvas` (19 files, including #27930's
`FlowCanvas.updateRecordSeed-27834`): 19 passed, 293 passed.
- `pnpm --filter @object-ui/app-shell run type-check`: exit 0 (lock
VERDICT command-exit 0).
- Ablation through `scripts/ablation-replace.mjs` (anchor 1 to 0): the
mount zoom back to `const z = 1;`: 1 failed / 3 passed (the 390px
branching case red); restored blob = HEAD blob `776392e9d921`, `git diff
HEAD` empty. vitest resolves `@object-ui/*` to source, so no rebuild
leg.
- `pnpm --dir ui run check:i18n-drift`: no en value changed.
</details>
## Acceptance notes
- **Row 22's second half is ALREADY DONE on our side.** The record
cards' lines already come from the object's `highlightFields`
(ADR-0085): `plugin-grid` `objectGridGenerateColumns` and `plugin-list`
`ListView` lead with them when the object declares them, and Studio's
object Settings tab edits them. "Account Name (Normalized)" is a HotCRM
field that is not `hidden`, on an object that declares no
`highlightFields`, so the default branch shows it. The fix is HotCRM's
metadata (declare `highlightFields`, or mark the field hidden), outside
this repo.
- The 40% floor is the canvas's existing `MIN_ZOOM`. A diagram wider
than 2.5 canvas widths still overflows at 40%; it was not measured on a
real HotCRM flow.
- Measured in happy-dom, which lays nothing out: the canvas and diagram
widths are the box the test sets and the layout's computed size, not a
rendered phone.
## Verification
On head `881dbf54` (tree identical to `bf7e1c77`, where they ran):
`dispatch-gates --commands` derived 34 families for this diff; all 34
were run locally, each exit 0, and `--ran` reconciled 34 run, 0
NOT-MEASURED, 0 UNRUN. `check:new-line-citations`: 0 new. CI check-runs
were in progress when this was opened.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CZrsFMFmWFsxTaq2Bu)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent f4826f8 commit 8f41b2d
3 files changed
Lines changed: 196 additions & 3 deletions
File tree
- .changeset
- ui/packages/app-shell/src/views/metadata-admin/previews
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 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 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
752 | 752 | | |
753 | 753 | | |
754 | 754 | | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
755 | 761 | | |
756 | 762 | | |
757 | 763 | | |
758 | | - | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
759 | 767 | | |
760 | | - | |
761 | | - | |
| 768 | + | |
| 769 | + | |
762 | 770 | | |
763 | 771 | | |
764 | 772 | | |
| |||
0 commit comments