Repository navigation
Commit e32d173
fix(plugin-form): a create wizard final-submit gate no longer judges the server lock readonlyWhen (#38487)
Fixes #38276
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:在多步骤“新建”向导里,某个必填字段带有“满足条件即锁定”的规则、且新记录的填写值恰好满足该条件时,向导在最后一步会像其它必填字段一样标出“必填”并跳回那一步,不再把空值提交给服务器后才报错;“编辑”向导的行为不变。
- 为什么做:向导最后一步的必填复查与表单本身的规则不一致,前一张同类问题(手动锁定规则)已修过一半,这次补上服务器锁定规则这一半。
- 出错会怎样:只影响新建向导提交前的提示,服务器照旧拒绝缺必填项的新建,不会写入错误数据;有问题可直接撤回。
- 要你做什么:无。
## What changes
`ui/packages/plugin-form/src/WizardForm.tsx`, `gateFinalSubmit`: the
field's server lock is now dropped on a CREATE wizard, mirroring the
hand-lock line beside it and the form renderer (`form.tsx` passes
`readonlyWhen: isCreateForm ? undefined : …` in every rule call):
```ts
readonlyWhen: isCreateWizard ? undefined : (field as any).readonlyWhen,
```
Ruling: ADR-0163, "The server lock": "A conditional lock is not judged
on a create, which is what makes `readonlyWhen: P\`true\`` set-once."
Before this change a `readonlyWhen` TRUE over the create wizard's own
values made the gate read the field as read-only and skip its required
check, so the create went out with the required field empty. An EDIT
wizard still judges the lock.
- Server side (triage asked): the insert does enforce `required`.
`packages/objectql/src/validation/record-validator.ts` `validateOne`,
the `// ── required` arm (`if (!skipRequired && def.required &&
isEmptyForRequired(def, value) …) return fail('required')`); its header
states "on INSERT a missing/null/empty value is rejected". The
`readonlyWhen` strip (`stripReadonlyWhenFields` in `rule-validator.ts`)
works on UPDATE payloads only. So no wrong row was ever stored; only the
client feedback was wrong.
- Contract face: none. No spec, schema, export or wire shape moves.
Read first: the one-line change in `gateFinalSubmit` (`WizardForm.tsx`),
then the new test file.
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-form/src/WizardForm.createServerLock-38276.test.tsx`
(expect 2 passed).
## Tests
New
`ui/packages/plugin-form/src/WizardForm.createServerLock-38276.test.tsx`
(3-step wizard with `allowSkip`; the required field sits on the skipped
middle step, so only `gateFinalSubmit` can judge it):
- a CREATE wizard whose field `readonlyWhen` is TRUE over its values
still demands the empty required field (the wizard returns to that step,
`create` not called);
- CONTROL: an EDIT wizard on a record where `readonlyWhen` holds treats
the field as locked and saves without it (`update` called once).
<details><summary>Readings at head 9e8bf75</summary>
- New file + `wizardPredicateScope.test.tsx`: `Test Files 2 passed (2)`,
`Tests 9 passed (9)`.
- Whole package `pnpm --dir ui exec vitest run --maxWorkers=2
packages/plugin-form/`: `Test Files 249 passed (249)`, `Tests 2807
passed | 1 skipped (2808)`.
- `pnpm --filter @object-ui/plugin-form run type-check` (`tsc --noEmit
&& tsc -p tsconfig.test.json`): exit 0; `--listFiles` on
`tsconfig.test.json` includes the new test file (1 hit).
- Ablation through `scripts/ablation-replace.mjs` (anchor hit 1 → 0,
blob d81437c → 9a490bfe): with the old line restored, the CREATE pin
fails (`Tests 1 failed | 1 passed (2)`) and the EDIT CONTROL stays
green; restore verified (blob == HEAD, `git diff HEAD` empty). The test
imports `./WizardForm` from source, so no dist rebuild was involved.
</details>
## Acceptance notes
- None beyond the card.
## Verification
Local: the derived gate list (`node scripts/pm/dispatch-gates.mjs
--commands`, 38 commands) run at head 9e8bf75; CI runs the full farm
and the type-check lanes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01FEkQ5pH8MaBBP5T2dVcTHL
Co-authored-by: Claude <noreply@anthropic.com>1 parent f4d02e6 commit e32d173
3 files changed
Lines changed: 135 additions & 1 deletion
File tree
- .changeset
- ui/packages/plugin-form/src
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
901 | 901 | | |
902 | 902 | | |
903 | 903 | | |
904 | | - | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
905 | 912 | | |
906 | 913 | | |
907 | 914 | | |
| |||
0 commit comments