Skip to content

Commit 1d51ee8

Browse files
committed
symplify how we determine that the object renderer should be used when the mixed renderer selected object type
1 parent 8a1b523 commit 1d51ee8

File tree

3 files changed

+24
-34
lines changed

3 files changed

+24
-34
lines changed

packages/vue-vuetify/src/complex/MixedRenderer.vue

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ import {
114114
} from 'vuetify/components';
115115
import { DisabledIconFocus } from '../controls';
116116
import {
117-
useCombinatorTranslations,
118117
IsDynamicPropertyContext,
118+
useCombinatorTranslations,
119119
useIcons,
120120
useJsonForms,
121121
useTranslator,
@@ -264,17 +264,25 @@ const createMixedRenderInfos = (
264264
scope: control.scope,
265265
};
266266
267+
const uischema = findUISchema(
268+
uischemas,
269+
schema,
270+
control.scope,
271+
path,
272+
() => createControlElement(control.scope ?? '#'),
273+
schemaControl,
274+
rootSchema,
275+
);
276+
277+
if (uischema.type === 'Control' && schema.type === 'object') {
278+
// override to specify exact type since the isObjectControl will check for empty scope
279+
// which in this case the scope is not empty
280+
uischema.type = 'Object';
281+
}
282+
267283
return {
268284
schema,
269-
uischema: findUISchema(
270-
uischemas,
271-
schema,
272-
control.scope,
273-
path,
274-
() => createControlElement(control.scope),
275-
schemaControl,
276-
rootSchema,
277-
),
285+
uischema,
278286
label: `${schema.type}`,
279287
};
280288
});
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import {
2-
isControl,
32
isObjectControl,
43
rankWith,
5-
resolveSchema,
64
type JsonFormsRendererRegistryEntry,
75
type JsonSchema,
86
type Scopable,
@@ -20,21 +18,8 @@ export const entry: JsonFormsRendererRegistryEntry = {
2018
uischema: UISchemaElement & Scopable,
2119
schema: JsonSchema,
2220
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-
},
21+
) =>
22+
isObjectControl(uischema, schema, context) ||
23+
(uischema.type === 'Object' && !isEmpty(uischema.scope)),
3924
),
4025
};

packages/vue-vuetify/src/complex/ObjectRenderer.vue

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
</template>
1818

1919
<script lang="ts">
20+
import { IsDynamicPropertyContext } from '@/util/inject';
2021
import {
2122
Generate,
2223
findUISchema,
@@ -33,10 +34,9 @@ import {
3334
import cloneDeep from 'lodash/cloneDeep';
3435
import isEmpty from 'lodash/isEmpty';
3536
import isObject from 'lodash/isObject';
36-
import { defineComponent, inject, provide } from 'vue';
37+
import { defineComponent, provide } from 'vue';
3738
import { useNested, useVuetifyControl } from '../util';
3839
import { AdditionalProperties } from './components';
39-
import { IsDynamicPropertyContext } from '@/util/inject';
4040
4141
const controlRenderer = defineComponent({
4242
name: 'object-renderer',
@@ -52,8 +52,6 @@ const controlRenderer = defineComponent({
5252
5353
const nested = useNested('object');
5454
55-
const isDynamic = inject<boolean>(IsDynamicPropertyContext, false);
56-
5755
// do not use the default value but the undefind so that
5856
// the property is cleared when property clear action is executed
5957
provide(IsDynamicPropertyContext, false);
@@ -62,7 +60,6 @@ const controlRenderer = defineComponent({
6260
...control,
6361
input: control,
6462
nested,
65-
isDynamic,
6663
};
6764
},
6865
computed: {
@@ -86,7 +83,7 @@ const controlRenderer = defineComponent({
8683
undefined,
8784
this.control.rootSchema,
8885
);
89-
if (isEmpty(this.control.path) || this.isDynamic) {
86+
if (isEmpty(this.control.path)) {
9087
uiSchema.type = 'VerticalLayout';
9188
} else {
9289
(uiSchema as GroupLayout).label = this.control.label;

0 commit comments

Comments
 (0)