Repository navigation
Commit 5ac50e4
fix(app-shell): optional choice rows in Studio metadata forms can be cleared again (#29805)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCo1bBWKzRoP44fkJR8d4fe)_
Fixes #29733
Clause-②: no
Metadata-protocol: none
Claim: 6595203212 (amendment 6595600429)
## 维护者速读
- 改了什么:Studio 元数据表单里「可选」的下拉选项(枚举字段)现在第一项是「— 无
—」,选它即把该键从元数据里删掉(恢复为「未声明」)。必填的下拉、以及列表里的单个元素不变,不出现这一项。另外修了同一条链路上的第二个原因:动作、仪表盘、钩子、页面、报表五个编辑器的「更多字段」区,清空任何一项(选「无」或清空文本框)以前会被宿主的合并立刻还原,现在清空能落到草稿并保存为「无此键」。
- 为什么改:卡片 #29733 指出可选枚举选过一次就回不去「未声明」;对 `user` 字段的 `deleteBehavior`
来说「未声明」本身就是一种生效的语义(不进删除级联)。实测发现 Studio 的字段面板目前根本不显示 `deleteBehavior`
这一行(席位另立卡),但缺陷本身在「更多字段」区可复现(动作的 `openIn` 只能在 self / new-tab 之间选)。
- 风险与回滚:只改界面,不动任何元数据契约;必填项、无值时的占位文字、合并逻辑本身都不变。清空的键以 `undefined` 进入草稿,保存时
JSON 自然省略。回滚即 revert 本 PR。
- 先看:`ui/packages/app-shell/src/views/metadata-admin/SchemaForm.tsx` 的
`offerUnset` 与两处 Select;`inspectors/fallbackFormPatch.ts`;五个
DefaultInspector 各一行 `onChange`。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/SchemaForm.optionalEnumUnset-29733.test.tsx
packages/app-shell/src/views/metadata-admin/inspectors/fallbackFormPatch-29733.test.tsx`,预期
12 个用例全部通过。
- 需要你做的:无,席位落地。
## What changes
**1. An optional enum select offers "— None —".** Both builtin select
paths of the metadata-admin `SchemaForm` (a form row's `options`, and a
schema property's own `enum`) listed only the enum values, so an
optional key, once picked, could never return to absent. `FieldControl`
now leads an optional row's list with a "— None —" item: the existing
`engine.form.none` key (en "— None —", zh "— 无 —"), the word the
metadata-admin pickers already use, so no new i18n key. Radix refuses an
item whose value is the empty string, so the item carries a sentinel
that `onValueChange` maps back to `undefined`, the form's existing clear
convention (`setField` deletes the key; a repeater row keeps an
`undefined` that serialisation drops). With nothing set, the trigger
still shows the "Select…" placeholder and nothing is written on render.
| Row | Before | Now |
|---|---|---|
| optional enum, either path | values only | "— None —" first, then the
values |
| required enum (schema `required`, a form row's `required`, a grid
column's `required`) | values only | unchanged |
| one element of a scalar list of an enum | values only | unchanged (an
element is removed with its own row button) |
**2. Clears in the "More fields" fallback form reach the draft.** The
action, dashboard, hook, page and report default inspectors render a
fallback `SchemaForm` and wired it `onChange={(next) => onPatch(next)}`.
The host's `onPatch` merges the patch over the draft, and `SchemaForm`
reports a clear by deleting the key from `next`, so the merge kept the
old value: a None pick, an emptied text box or an emptied number box
there was undone at once. The new pure helper `fallbackFormPatch(draft,
next)` returns `next` plus every key the draft had and `next` dropped,
set to `undefined`; the five call sites route through it. `onPatch`'s
merge itself is unchanged, and a key the form did not touch is never
turned into `undefined`.
## Tests
- `SchemaForm.optionalEnumUnset-29733.test.tsx` (new, 8), over the real
`SchemaForm`: the schema-enum path and the form-options path each emit
an object without the key after "— None —" (nothing else moves); a
repeater card row (the object form's `fields` rows, where
`deleteBehavior` sits) serialises without the key; the placeholder still
shows and nothing is emitted on render. CONTROLS: a required enum on
each path offers no None item; in a grid repeater a required column
offers none while an optional one does; a scalar list element offers
none.
- `inspectors/fallbackFormPatch-29733.test.tsx` (new, 4): the helper
through a merge leaves a cleared key absent and an edited key at its new
value; CONTROL: untouched keys pass through and nothing becomes
`undefined`; the real `ActionDefaultInspector` under a merging host: "—
None —" on `openIn` and an emptied `description` each leave the draft
without the key, with the curated keys untouched.
- Ablations (`scripts/ablation-replace.mjs`, each restored to the HEAD
blob with `git diff HEAD` empty): A1 `offerUnset` forced false, 4 of 8
red (the three positive pins and the grid optional column), the 4
controls green. A2 the helper's undefined-for-dropped-key line removed,
3 of 4 red, the control green.
- Touched suites, under the verify lock at `--maxWorkers=2`: the 144 ui
test files that name `SchemaForm`, one of the five inspectors or
`engine.form.none` (`git grep -l`), 1464 tests, all green.
## Acceptance notes
- **The card's named door is not reachable in Studio today (measured).**
The Studio object designer's field panel (`ObjectFieldInspector`) offers
no Delete Behavior row on a `user` field nor on a `lookup` field; the
`deleteBehavior` rows live in `object.form.ts` / `field.form.ts`, which
`SchemaForm` renders, and for `object` the editor shows the designer and
its inspectors instead. So the named consequence (a cascade or restrict
left in force on a `user` field) is prevented here for the moment a form
that renders those rows is reached. The missing row in the designer's
field panel is filed by the seat as its own finding.
- **Surface:** widened by claim amendment 6595600429 to the five
default-inspector `onChange` call sites and one helper, after the live
run showed a None item alone would be a dead control there. Clearing a
text box or a number box in those fallback forms is fixed by the same
change.
- **Defaults:** an enum whose schema carries a `default` is listed in
the served schema's `required` and so offers no None item (hook
`onError`, `runAs`). That is the existing required signal, not changed
here.
- **Not changed:** the action inspector's own curated `variant` select
(an `InspectorSelectField`, not `SchemaForm`) still has no unset item;
it is outside this card.
- Narrowing declared: the full `packages/app-shell` suite is CI's (Test
UI); locally the 144-file grep set above ran.
## Verification
Real backend (`examples/app-crm`, `objectstack dev --fresh`) and the
source Console (Vite on `ui/apps/console`), admin session, a scratch
package with an object `udb_ticket` (a `user` field `assignee`, a
`lookup` field `parent_ticket`) and an action `udb_escalate` (`type:
url`, `openIn: self`). Screenshots are in the project folder
(`issue-29733/`), not on GitHub.
<details><summary>Before (main 6f09464), the "More fields" Open In
select on the action</summary>
- Options read `["self","new-tab"]`: no way back to absent.
- With only the SchemaForm half applied, picking "— None —" left the
trigger at `self`: the merging host kept the key.
- The field panel for `assignee` (user) and `parent_ticket` (lookup)
shows no Delete Behavior row.
</details>
<details><summary>After, on this branch</summary>
- Options read `["— None —","self","new-tab"]`.
- Pick "— None —": the trigger shows the "Select…" placeholder; Save
(draft), reload: still unset; Publish.
- `GET /api/v1/meta/action/udb_escalate` after publish: the item carries
no `openIn` (before it read `"openIn":"self"`).
</details>
<details><summary>Local gates</summary>
On head `74e47d1e` (main merged at `25450217`; 11 later main commits
touch none of this PR's files): `node scripts/pm/dispatch-gates.mjs
--commands` derives 35 commands; each ran with exit 0
(`check:type-check-debt` and `pnpm --dir ui exec vitest run scripts/`
under the verify lock), and `--ran` reconciles 35 derived, 35 run, 0
NOT-MEASURED. Also exit 0: `pnpm --filter @object-ui/app-shell run
type-check`; `eslint` on the 9 touched files (0 errors; the warnings are
on untouched lines); `check-partof-closing-keyword`;
`check-closing-keyword-parity --body` (binds only this card). The two
new test files rerun on this head: 12/12. `dispatch-gates --tier`: no
path-derived mandate (default tier); 520 changed lines before the main
merge, under 3000. The repo-wide sweep (`pnpm lint` and the rest of the
farm) is CI's.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jUDMc41NruhHkjaN5X)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 138dacf commit 5ac50e4
10 files changed
Lines changed: 512 additions & 8 deletions
File tree
- .changeset
- ui/packages/app-shell/src/views/metadata-admin
- inspectors
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 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 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
0 commit comments