Skip to content

Commit ef24610

Browse files
committed
if the schema is an object that is selected because of mixed type then also allow such case to be handled by the object renderer
1 parent 89bfb0b commit ef24610

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed
Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
11
import {
2+
isControl,
23
isObjectControl,
34
rankWith,
5+
resolveSchema,
46
type JsonFormsRendererRegistryEntry,
7+
type JsonSchema,
8+
type Scopable,
9+
type TesterContext,
10+
type UISchemaElement,
511
} from '@jsonforms/core';
612
import controlRenderer from './ObjectRenderer.vue';
13+
import isEmpty from 'lodash/isEmpty';
714

815
export const entry: JsonFormsRendererRegistryEntry = {
916
renderer: controlRenderer,
10-
tester: rankWith(2, isObjectControl),
17+
tester: rankWith(
18+
2,
19+
(
20+
uischema: UISchemaElement & Scopable,
21+
schema: JsonSchema,
22+
context: TesterContext,
23+
) => {
24+
return (
25+
isObjectControl(uischema, schema, context) ||
26+
// schemaMatches that is used inside the isObjectControl uses a resolve of the current schema which when the schema is provided as resolved for the MixedRender then there is no need for further resolve
27+
(isControl(uischema) &&
28+
!isEmpty(uischema.scope) &&
29+
schema?.type === 'object' &&
30+
Array.isArray(
31+
resolveSchema(
32+
context.rootSchema,
33+
uischema.scope,
34+
context.rootSchema,
35+
)?.type,
36+
))
37+
);
38+
},
39+
),
1140
};

0 commit comments

Comments
 (0)