Repository navigation
Commit 1aac465
fix(plugin-form): judge the wizard final-submit gate on computed formula values (#35348)
Fixes #35189
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:向导表单(以及简单表单的移动端分步模式)最终提交前的必填检查,现在先按对象的公式字段重新计算记录,再判断字段的
`visibleWhen`,与普通表单的做法一致。
- 为什么改:之前用的是上次读取时的旧公式值。改动让字段移出条件后,向导仍要求填写服务端并不要求的字段;移入条件后,又放过了服务端会拒收的提交。
- 风险与回滚:只改了 `WizardForm.tsx` 的最终提交检查,不改 spec、服务端和 i18n。回滚就是 revert 这个
PR。
- 先看:`ui/packages/plugin-form/src/WizardForm.tsx`(`gateFinalSubmit` 中的
`ruleRecord` 与
`formulaPlan`)、`ui/packages/plugin-form/src/__tests__/wizardFormulaGate-35189.test.tsx`、`.changeset/35189-wizard-gate-formula.md`。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/plugin-form/src/__tests__/wizardFormulaGate-35189.test.tsx`,预期
5 passed;把 `WizardForm.tsx` 换回 main 的版本后再跑,预期 3 failed / 2 passed。
- 需要你做的:无,席位落地。
## What changes
- `WizardForm` plans the object's `formula` fields once, from the object
schema it already reads (`planObjectFormulas` from `@object-ui/core`,
for the acting user of the predicate scope). No second schema read and
no new export.
- `gateFinalSubmit` judges `resolveFieldRuleState` and the view-level
`visibleOn` on `formulaPlan.compute(record)`: the value a read of the
written record would serve, as `form.tsx` and `FormPage.tsx` do
(ADR-0113, formula paragraph). Emptiness is still read off the written
record.
- A `visibleWhen` that reads a formula the form cannot compute
(`plan.unservableReadsOf`) is dropped in the gate, the same way the step
form's `withoutUnservableVisibleWhen` drops it. The field counts as
shown, keeps `required` and raises no fault.
- Unchanged, as dispatched: if there is no `getObjectSchema`, or the
schema read fails, there is no plan, and the gate judges the record as
it holds it.
## Tests
New `wizardFormulaGate-35189.test.tsx`: an edit wizard with a required
field on a skipped step, whose `visibleWhen` reads a formula.
- An edit moves the formula out of the condition: the save goes through.
- An edit moves the formula into the condition: the save is refused, and
the wizard marks and opens the step that holds the field.
- The `visibleWhen` reads an unservable formula (through a lookup): the
field counts as shown and required, so the save is refused.
- Two controls read the same condition straight off a stored column.
They pass before and after the fix.
<details><summary>Red on main, green with the fix</summary>
- Fix applied: `VERDICT command-exit 0`, Tests 5 passed (5).
- `WizardForm.tsx` taken from main (planObjectFormulas count 0):
`VERDICT command-exit 1`, Tests 3 failed / 2 passed (5). The three
formula legs are red and both controls are green. The fixed file was
restored with a matching blob hash.
</details>
<details><summary>Package suite and type-check (tree f2cc860)</summary>
- `pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/`:
`VERDICT command-exit 0`, Test Files 238 passed (238), Tests 2678 passed
/ 1 skipped.
- `pnpm --filter @object-ui/plugin-form type-check`: `VERDICT
command-exit 0`. The test program lists the new test file.
</details>
## Acceptance notes
- Explicit data-source prop with no renderer context (not filed, reach
not measured). The step form plans its formulas from the
`SchemaRendererProvider` context only (`useObjectFormulaPlan` in
`form.tsx`), but `WizardForm` also accepts an explicit `dataSource`
prop. A host that passes only the prop now gets a final gate that
computes formulas and a step form that judges the stale value. After an
edit that moves a required field into its condition, the gate refuses
and opens a step whose form hides the field. Before this PR, the server
refused that save with a 400 that named the same hidden field. Hosts
that mount the renderer context (the Console) do not hit this. I did not
reproduce it through a public entry point.
- The residual where a missing or failed schema read gives no plan is
unchanged.
## Verification
<details><summary>Derived gate families (dispatch-gates, 3
paths)</summary>
- 38 derived commands. 37 exited 0 on the first pass. `pnpm --dir ui
exec vitest run scripts/` was killed by the container's out-of-memory
killer and was re-run under the verify lock with two workers: `VERDICT
command-exit 0`, 171 files passed / 2 skipped.
- `--ran` reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN.
- `node scripts/pm/overlap-check.mjs`: `VERDICT clean exit 0` (merges
cleanly with origin/main e4bfa33, 0 PR heads overlap).
- Every other family is left to this PR's CI check-runs.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CajiB6BSQKWowy6YLB)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8f49499 commit 1aac465
3 files changed
Lines changed: 215 additions & 4 deletions
File tree
- .changeset
- ui/packages/plugin-form/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
800 | 801 | | |
801 | 802 | | |
802 | 803 | | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
803 | 818 | | |
804 | 819 | | |
805 | 820 | | |
| |||
868 | 883 | | |
869 | 884 | | |
870 | 885 | | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
871 | 890 | | |
872 | 891 | | |
873 | 892 | | |
874 | 893 | | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
875 | 901 | | |
876 | 902 | | |
877 | | - | |
| 903 | + | |
878 | 904 | | |
879 | 905 | | |
880 | 906 | | |
881 | | - | |
| 907 | + | |
882 | 908 | | |
883 | 909 | | |
884 | 910 | | |
| |||
913 | 939 | | |
914 | 940 | | |
915 | 941 | | |
916 | | - | |
| 942 | + | |
917 | 943 | | |
918 | 944 | | |
919 | 945 | | |
| |||
938 | 964 | | |
939 | 965 | | |
940 | 966 | | |
941 | | - | |
| 967 | + | |
942 | 968 | | |
943 | 969 | | |
944 | 970 | | |
| |||
| 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 | + | |
0 commit comments