Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e41c15d
preserve the form data so when we update the additionalErrors the dat…
kchobantonov Aug 12, 2025
a6a21e3
Merge branch 'master' into preserve-edit-data
kchobantonov Aug 15, 2025
d5218b1
also update the schema and uischema when they depend on the data and …
kchobantonov Aug 23, 2025
0b979c0
properly generate schema in case when the data is not an object but s…
kchobantonov Aug 23, 2025
ebe262b
always return valid UISchemaElement, in case of empty schema this was…
kchobantonov Aug 24, 2025
51aa0bc
revert back the ability to return null from the generate but default …
kchobantonov Aug 24, 2025
b27ce7f
only for undefined use emtpy data for others the core can handle those
kchobantonov Sep 5, 2025
87bfaa6
Merge branch 'master' into preserve-edit-data
kchobantonov Sep 27, 2025
e413248
Merge branch 'master' into preserve-edit-data
kchobantonov Nov 7, 2025
7bde214
Merge branch 'master' into preserve-edit-data
kchobantonov Nov 10, 2025
6f736d2
Merge branch 'master' into preserve-edit-data
kchobantonov Nov 10, 2025
4803dec
Merge branch 'master' into preserve-edit-data
kchobantonov Dec 2, 2025
22b4016
Merge branch 'master' into preserve-edit-data
kchobantonov Dec 16, 2025
fd04fe0
Merge branch 'master' into preserve-edit-data
kchobantonov Jan 23, 2026
d9de6ab
Merge branch 'master' into preserve-edit-data
kchobantonov Feb 15, 2026
63f16bf
Merge branch 'master' into preserve-edit-data
kchobantonov Mar 1, 2026
972c194
Merge branch 'master' into preserve-edit-data
kchobantonov Mar 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/generators/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,5 @@ export const generateJsonSchema = (

const gen = new Gen(findOption);

return gen.schemaObject(instance);
return gen.property(instance);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No tests cover the new behavior. All existing tests in schema.test.ts pass objects. Tests for generateJsonSchema("hello"), generateJsonSchema(42), generateJsonSchema([1,2]) etc. are needed.

};
1 change: 0 additions & 1 deletion packages/vue-vuetify/dev/views/ExampleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ const onChange = (event: JsonFormsChangeEvent): void => {
monaco.Uri.parse(toDataUri(props.example.name)),
event.data !== undefined ? JSON.stringify(event.data, null, 2) : '',
);
state.data = event.data;
}
errors.value = event.errors;
};
Expand Down
55 changes: 26 additions & 29 deletions packages/vue/src/components/JsonForms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,24 @@ import {
defaultMiddleware,
Middleware,
JsonFormsSubStates,
Layout,
} from '@jsonforms/core';
import { JsonFormsChangeEvent, MaybeReadonly } from '../types';
import DispatchRenderer from './DispatchRenderer.vue';

import type Ajv from 'ajv';
import type { ErrorObject } from 'ajv';

// TODO fix @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/ban-types
const isObject = (elem: any): elem is Object => {
return elem && typeof elem === 'object';
};

const EMPTY: ErrorObject[] = reactive([]);

const createDefaultLayout = (): Layout => ({
type: 'VerticalLayout',
elements: [],
});
const generateUISchema = (schema: JsonSchema) =>
Generate.uiSchema(schema, undefined, undefined, schema) ??
createDefaultLayout();

export default defineComponent({
name: 'JsonForms',
components: {
Expand Down Expand Up @@ -123,13 +126,10 @@ export default defineComponent({
},
emits: ['change'],
data() {
const dataToUse = this.data;
const generatorData = isObject(dataToUse) ? dataToUse : {};
const dataToUse = this.data === undefined ? {} : this.data;
const schemaToUse: JsonSchema =
this.schema ?? Generate.jsonSchema(generatorData);
const uischemaToUse =
this.uischema ??
Generate.uiSchema(schemaToUse, undefined, undefined, schemaToUse);
this.schema ?? Generate.jsonSchema(dataToUse);
const uischemaToUse = this.uischema ?? generateUISchema(schemaToUse);
const initCore = (): JsonFormsCore => {
const initialCore = {
data: dataToUse,
Expand Down Expand Up @@ -189,29 +189,23 @@ export default defineComponent({
},
watch: {
schema(newSchema) {
const generatorData = isObject(this.data) ? this.data : {};
this.schemaToUse = newSchema ?? Generate.jsonSchema(generatorData);
this.schemaToUse = newSchema ?? Generate.jsonSchema(this.dataToUse);
if (!this.uischema) {
this.uischemaToUse = Generate.uiSchema(
this.schemaToUse,
undefined,
undefined,
this.schemaToUse
);
this.uischemaToUse = generateUISchema(this.schemaToUse);
}
},
uischema(newUischema) {
this.uischemaToUse =
newUischema ??
Generate.uiSchema(
this.schemaToUse,
undefined,
undefined,
this.schemaToUse
);
this.uischemaToUse = newUischema ?? generateUISchema(this.schemaToUse);
},
data(newData) {
this.dataToUse = newData;
this.dataToUse = newData === undefined ? {} : newData;

if (!this.schema) {
Comment on lines 200 to +203
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combined with the other change sof the PR, this means that on every user edit (in schema-less mode) the schema and uischema are regenerated from the core's data, which is expensive and likely unnecessary since the shape of the data typically doesn't change between edits the user can make through JSON Forms

We need to differentiate between outside and user based changes and only regenerate on outside changes.

this.schemaToUse = Generate.jsonSchema(this.dataToUse);
if (!this.uischema) {
this.uischemaToUse = generateUISchema(this.schemaToUse);
}
}
},
renderers(newRenderers) {
this.jsonforms.renderers = newRenderers;
Expand Down Expand Up @@ -251,6 +245,9 @@ export default defineComponent({
);
},
eventToEmit(newEvent) {
// update the data so if we change the additionalErrors this won't reset the form data
this.dataToUse = newEvent.data;

this.$emit('change', newEvent);
},
i18n: {
Expand Down