Skip to content

Commit 961363d

Browse files
committed
vue-vuetify: Fix oneOf renderers not clearing some primitive values
Replace isEmpty check with check against undefined because isEmpty always returns true for boolean values, 0, empty strings and objects without props. This could lead to errors when switching from any of these to an array and trying to add elements there.
1 parent 0905630 commit 961363d

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ import {
9090
type RendererProps,
9191
useJsonFormsOneOfControl,
9292
} from '@jsonforms/vue';
93-
import isEmpty from 'lodash/isEmpty';
9493
import { defineComponent, ref } from 'vue';
9594
import {
9695
VBtn,
@@ -138,7 +137,7 @@ const controlRenderer = defineComponent({
138137
control.indexOfFittingSchema != null &&
139138
control.indexOfFittingSchema != undefined // use the fitting schema if found
140139
? control.indexOfFittingSchema
141-
: !isEmpty(input.control.value.data)
140+
: input.control.value.data !== undefined
142141
? 0 // uses the first schema and report errors if not empty
143142
: null,
144143
);
@@ -176,7 +175,7 @@ const controlRenderer = defineComponent({
176175
handleSelectChange(selectIndex: number | null): void {
177176
this.newSelectedIndex = selectIndex;
178177
179-
if (isEmpty(this.control.data)) {
178+
if (this.control.data === undefined) {
180179
this.openNewTab(this.newSelectedIndex);
181180
} else {
182181
this.dialog = true;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ import {
7676
type RendererProps,
7777
useJsonFormsOneOfControl,
7878
} from '@jsonforms/vue';
79-
import isEmpty from 'lodash/isEmpty';
8079
import { defineComponent, ref } from 'vue';
8180
import {
8281
VBtn,
@@ -156,7 +155,7 @@ const controlRenderer = defineComponent({
156155
// revert back to the orginal value until the dialog is done
157156
this.selectIndex = this.selectedIndex;
158157
159-
if (isEmpty(this.control.data)) {
158+
if (this.control.data === undefined) {
160159
this.openNewTab(this.newSelectedIndex);
161160
} else {
162161
this.dialog = true;

0 commit comments

Comments
 (0)