diff --git a/packages/core/src/util/combinators.ts b/packages/core/src/util/combinators.ts index 9ebb3b6cc..60cb0f7f9 100644 --- a/packages/core/src/util/combinators.ts +++ b/packages/core/src/util/combinators.ts @@ -62,7 +62,7 @@ export const createCombinatorRenderInfos = ( ), label: subSchema.title ?? - resolvedSubSchema.title ?? + resolvedSubSchema?.title ?? `${keyword}-${subSchemaIndex}`, }; }); diff --git a/packages/core/test/util/combinators.test.ts b/packages/core/test/util/combinators.test.ts index 548760967..8b9115683 100644 --- a/packages/core/test/util/combinators.test.ts +++ b/packages/core/test/util/combinators.test.ts @@ -80,3 +80,34 @@ test('createCombinatorRenderInfos - uses overrides for labels when subschemas ar t.deepEqual(duaRenderInfo.label, 'DuaOverride'); t.deepEqual(lipaRenderInfo.label, 'LipaOverride'); }); + +const schemaWithoutRefs = { + type: 'object', + properties: { + widget: { + anyOf: [ + { + type: 'object', + properties: { name: { type: 'string' } }, + }, + { + type: 'object', + properties: { name: { type: 'string' } }, + }, + ], + }, + }, +}; + +test('createCombinatorRenderInfos - uses keyword + index when no labels provided', (t) => { + const [duaRenderInfo, lipaRenderInfo] = createCombinatorRenderInfos( + schemaWithoutRefs.properties.widget.anyOf, + schemaWithoutRefs, + 'anyOf', + control, + 'widget', + [] + ); + t.deepEqual(duaRenderInfo.label, 'anyOf-0'); + t.deepEqual(lipaRenderInfo.label, 'anyOf-1'); +});