Skip to content

Commit 09dce24

Browse files
committed
[form] Fix nested additional properties id's inference
1 parent cbf6bd5 commit 09dce24

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

.changeset/warm-actors-compare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sjsf/form": patch
3+
---
4+
5+
Fix nested additional properties id's inference

packages/form/src/form/context/id-schema.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,11 @@ export function makeArrayItemId(
4848
) {
4949
return `${parentId}${ctx.idSeparator}${index}`;
5050
}
51+
52+
export function makeObjectPropertyId(
53+
ctx: FormContext,
54+
parentId: string,
55+
property: string
56+
) {
57+
return `${parentId}${ctx.idSeparator}${property}`
58+
}

packages/form/src/form/fields/object/object-field.svelte

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
} from "@/core/index.js";
1515
1616
import type { UiSchema } from "../../ui-schema.js";
17-
import { FAKE_ID_SCHEMA } from "../../id-schema.js";
1817
import {
1918
getTemplate,
2019
getComponent,
@@ -26,6 +25,8 @@
2625
retrieveSchema,
2726
getFormContext,
2827
validateField,
28+
makeIdSchema,
29+
makeObjectPropertyId,
2930
} from "../../context/index.js";
3031
import { AFTER_SUBMITTED, ON_OBJECT_CHANGE } from "../../validation.js";
3132
@@ -181,7 +182,14 @@
181182
schema: propSchema,
182183
uiSchema: propUiSchema,
183184
uiOptions: propUiOptions,
184-
idSchema: config.idSchema[property] ?? FAKE_ID_SCHEMA,
185+
idSchema:
186+
config.idSchema[property] ??
187+
makeIdSchema(
188+
ctx,
189+
propSchema,
190+
makeObjectPropertyId(ctx, config.idSchema.$id, property),
191+
value[property]
192+
),
185193
required: requiredProperties.has(property),
186194
}}
187195
/>

0 commit comments

Comments
 (0)