Skip to content

Conversation

@kchobantonov
Copy link
Contributor

…a is not reset to the initial state

@netlify
Copy link

netlify bot commented Aug 12, 2025

Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit 6f736d2
🔍 Latest deploy log https://app.netlify.com/projects/jsonforms-examples/deploys/6912310df068490008717b1b
😎 Deploy Preview https://deploy-preview-2478--jsonforms-examples.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kchobantonov
Copy link
Contributor Author

@sdirix please review, to check the issue in the current master branch just apply the change for ExampleView.vue and then try to test the additional-errors example, e.g. change the form once it is loaded and then click on the "Add Additonal Error" button and observe that the form data is reset, then check the https://deploy-preview-2478--jsonforms-examples.netlify.app/vue-vuetify/#additional-errors

@coveralls
Copy link

coveralls commented Aug 13, 2025

Coverage Status

coverage: 82.798%. remained the same
when pulling 6f736d2 on kchobantonov:preserve-edit-data
into b1c72e8 on eclipsesource:master.

@sdirix
Copy link
Member

sdirix commented Aug 13, 2025

So the error occurs only if the user of JSON Forms:

  • hands over new additionalErrors to JSON Forms component
  • does not hand over an updated state of the the data

I don't think that this is a valid use case. Either the props of the JSON Forms component are "frozen" and the management is done by JSON Forms, or the props are always live. The error case is a weird mix which is not really valid.

The same issue will occur in Angular and React if only parts of the props are updated. Either they should never be updated by the user, i.e. uncontrolled variant, or they should all be updated, i.e. controlled variant.

@kchobantonov
Copy link
Contributor Author

I understand the distinction between controlled and uncontrolled usage, but in practice consumers of JSON Forms may mix these patterns—intentionally or unintentionally—especially in larger applications with multiple state sources.
From a robustness standpoint, the component should ideally handle all variants, including partial updates.

Even if this “weird mix” is not the recommended pattern, supporting it makes JSON Forms more fault-tolerant and easier to integrate in real-world scenarios where the state flow is not always perfectly aligned with controlled/uncontrolled paradigms.

@kchobantonov
Copy link
Contributor Author

@sdirix @lucas-koehler please also check the update where the generated schema and uischema are properly regenerated when the data is changes - please check this example dynamic when if you change the data to a number and save then the ui will be updated accordingly - in previous versions that was not true.

@kchobantonov
Copy link
Contributor Author

@sdirix please review

@lucas-koehler lucas-koehler force-pushed the master branch 4 times, most recently from 24c8cb2 to d86047e Compare October 24, 2025 10:26
@kchobantonov
Copy link
Contributor Author

@sdirix @lucas-koehler please review

Copy link
Contributor

@lucas-koehler lucas-koehler left a comment

Choose a reason for hiding this comment

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

Hi @kchobantonov ,
Thanks for the updates! I have some comments inline unrelated to the setting of this.dataToUse = newEvent.data;.

I am still a bit concerned about this:

  • It makes the data propagation less intuitive:
    • In the controlled case, the data is set to dataToUse again after it has already been updated. Granted, this does not trigger an additional invocation of coreDataToUpdate().
    • In the uncontrolled case, this triggers coreDataToUpdate an additional time without it being needed. This has a possible performance penalty because it invokes the middleware again
    • In the mixed case, it triggers the coreDataToUpdate like in the uncontrolled case. From a data point of view that should also not be necessary because the data is uncontrolled. Granted, this is acceptable considering the issues that this tries to fix.

As this does make the state handling less intuitive and lowers performance in uncontrolled mode as far as I can tell, I am leaning towards not introducing supporting this mixed case.

Do you have a concrete use case in mind where this is necessary? For a diffuse robustness increase, I prefer to not introduce this because consumers can always control the data in the component rendering the form. Even if the state handling is more complex for other properties.
We can of course add this to the documentation though.

},
data(newData) {
this.dataToUse = newData;
this.dataToUse = newData === undefined ? {} : newData;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this necessary? For instance, we don't do this in React

Comment on lines +39 to +45
const createDefaultLayout = (): Layout => ({
type: 'VerticalLayout',
elements: [],
});
const generateUISchema = (schema: JsonSchema) =>
Generate.uiSchema(schema, undefined, undefined, schema) ??
createDefaultLayout();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is behavior that shouldn't be defined specifically here. If the Generator does not handle this already, we might fix it there for all.

monaco.Uri.parse(toDataUri(props.example.name)),
event.data !== undefined ? JSON.stringify(event.data, null, 2) : '',
);
state.data = event.data;
Copy link
Contributor

Choose a reason for hiding this comment

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

I get that this is introduced to test the new behavior but even if we were to merge it, I don't think the example app use this unrecommended mixed approach. Thus, this should be reverted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants