Skip to content

Commit e04df21

Browse files
committed
remove no-gutters and use v-if to check visibility so we can remove invisible elements to not have extra padding from the v-col
1 parent 1c751ab commit e04df21

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

packages/vue-vuetify/src/layouts/VerticalLayoutRenderer.vue

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
<v-row
1010
v-for="(element, index) in (layout.uischema as Layout).elements"
1111
:key="`${layout.path}-${(layout.uischema as Layout).elements.length}-${index}`"
12-
no-gutters
1312
v-bind="vuetifyProps(`v-row[${index}]`)"
1413
>
1514
<v-col
1615
cols="12"
16+
v-if="isVisible(element, layout.path)"
1717
:class="styles.verticalLayout.item"
1818
v-bind="vuetifyProps('v-col')"
1919
>
@@ -31,7 +31,15 @@
3131
</template>
3232

3333
<script lang="ts">
34-
import { type Layout } from '@jsonforms/core';
34+
import {
35+
getAjv,
36+
getConfig,
37+
getData,
38+
hasShowRule,
39+
isVisible,
40+
type Layout,
41+
type UISchemaElement,
42+
} from '@jsonforms/core';
3543
import {
3644
DispatchRenderer,
3745
rendererProps,
@@ -40,7 +48,7 @@ import {
4048
} from '@jsonforms/vue';
4149
import { defineComponent } from 'vue';
4250
import { VCol, VContainer, VRow } from 'vuetify/components';
43-
import { useVuetifyLayout } from '../util';
51+
import { useJsonForms, useVuetifyLayout } from '../util';
4452
4553
const layoutRenderer = defineComponent({
4654
name: 'vertical-layout-renderer',
@@ -54,7 +62,26 @@ const layoutRenderer = defineComponent({
5462
...rendererProps<Layout>(),
5563
},
5664
setup(props: RendererProps<Layout>) {
57-
return useVuetifyLayout(useJsonFormsLayout(props));
65+
const jsonforms = useJsonForms();
66+
return { ...useVuetifyLayout(useJsonFormsLayout(props)), jsonforms };
67+
},
68+
methods: {
69+
// helper method to check visibility and if not visible to remove the v-col since otherwise it will add extra padding
70+
isVisible(uischema: UISchemaElement, path: string): boolean {
71+
if (hasShowRule(uischema)) {
72+
const state = { jsonforms: this.jsonforms };
73+
const rootData = getData(state);
74+
75+
return isVisible(
76+
uischema,
77+
rootData,
78+
path,
79+
getAjv(state),
80+
getConfig(state),
81+
);
82+
}
83+
return true;
84+
},
5885
},
5986
});
6087

0 commit comments

Comments
 (0)