Skip to content

Commit eb20613

Browse files
committed
fix(app-shell): a served form item takes .form only when it is the default
`applyViewItem` no longer makes the first form item to arrive the object's create/edit `.form` when no item carries `isDefault`. `ViewSchema.form` is a container's default form view and `formViews` are additional named form views, so a container with no `form` leaves `.form` unset, and a named form is reached only by its name. Claude-Session: https://claude.ai/code/session_01FjqrwXPfSMkSfkKYDSRkN2 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6f5719e commit eb20613

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎packages/app-shell/src/providers/MetadataProvider.tsx‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,20 @@ function viewItemBody(view: any): Record<string, any> {
409409
* with the id so primary-view promotion (which matches on `list.name`) finds
410410
* this entry by its listViews key.
411411
* FORM-family views land in `formViews` only, never in the list-view switcher.
412+
*
413+
* `bucket.form` — what create and edit render — is set ONLY from a form item
414+
* that carries `isDefault` (objectui#11539). `@objectstack/spec` `ViewSchema`
415+
* calls a container's `form` its "Default form view" and `formViews`
416+
* "Additional named form views", and the served rows say which one is default:
417+
* `OBJECT.form` alone carries `isDefault`. There is no "first form wins"
418+
* fallback, so arrival order decides nothing: a default arriving after a named
419+
* form still takes `.form`, and a named form arriving after the default does
420+
* not displace it. A container with no `form` serves its named forms with no
421+
* `isDefault`, and `.form` stays unset. Create and edit then take the path an
422+
* object with no default form view takes: `resolveFormViewLayout` returns no
423+
* sections, and the dialog lays out the object's own fields. A named form —
424+
* which can be a public anonymous intake form or a wizard — is reached only by
425+
* its name, through `formViews`.
412426
*/
413427
function applyViewItem(bucket: ViewBucket, view: any): void {
414428
const key = view.name || `${view.object}.${view.viewKind}`;
@@ -421,7 +435,7 @@ function applyViewItem(bucket: ViewBucket, view: any): void {
421435
};
422436
if (view.viewKind === 'form') {
423437
bucket.formViews[key] = entry;
424-
if (view.isDefault || !bucket.form) bucket.form = entry;
438+
if (view.isDefault) bucket.form = entry;
425439
} else {
426440
bucket.listViews[key] = entry;
427441
if (view.isDefault) bucket.primary = entry;

0 commit comments

Comments
 (0)