koumoul-dev / vuetify-jsonschema-form

Create beautiful and low-effort forms that output valid data. Published on npm as @koumoul/vjsf.
https://koumoul-dev.github.io/vuetify-jsonschema-form/latest/
MIT License
546 stars 155 forks source link

A couple strange behaviors on input #456

Open saveliy-sviridov opened 2 weeks ago

saveliy-sviridov commented 2 weeks ago

Hi, I have noticed a couple of issues when inputting values into the form that seem to not have been present before (although I don't know exactly when they appeared as I've only recently migrated to the vue3 version):

These are obviously not massive problems, but they seem somewhat obscure so I wanted to bring them to your attention.

albanm commented 2 weeks ago

Yes, thanks, I will have a look.

albanm commented 1 week ago

This turned out to have somewhat complicated implications. There are quite large changes in the latest beta release, hopefully this should fix some bug as well as improve performance in some cases.

The first bug should be fixed.

About the second bug, for clarification : validateOn doest not control when the ajv validation is performed, but rather when the fields are considered as validated by the user (and so when errors should be displayed in the UI). Still there was a bug indeed. At least one case is fixed, I you still encounter an invalid behavior feel free to reopen the issue.

saveliy-sviridov commented 1 week ago

Thank you very much for a fast response (as usual!)

The first bug indeed seems to be completely resolved, but sadly I'm experiencing some very strange behavior in beta.46, although this is perhaps due to my implementation.

I'm using a property directly from my pinia store as vjsf's v-model with toRefs(store) (this is perhaps unadvisable?), which seems to have worked mroe or less properly before, however, in the latest version, when I manually edit any value in the form for the first time (after it gets initially hydrated with data from the store), the entire form is emptied except for the value I edited. The consequent edits, however, work just as expected.

Additionally, whenever I update the value in the store by any other mean, the form updates as well, and displays the correct data... however if I once again modify any value in the form manually, it goes back to the previous state, as if there were two forms - one that's correctly displaying the data from the store and the other that is completely independent from it.

Would you happen to have any idea what could be causing this? Could this indeed be related to my using a state value as v-model, or does that have nothing to do with it?

Also, please let me know if you would prefer that I create a separate issue for this.

albanm commented 1 week ago

No need to open a new issue.

Are you sure the vjsf version is the only change in the code base ? For now I fail to see what could cause what you observe. Using the editor shows that data-binding works in both directions (input from the form and applying external mutations). I don't know why using some state value from pinia would change that if it is exposed as a normal ref by toRefs.

If you don't find the bug yourself you can post some reproduction. I don't know what the best way to do it would be, maybe you could work in this directory in a fork.

saveliy-sviridov commented 1 week ago

Yeah, I've re-checked and it is indeed just the vjsf version; specifically the issue arises when going from beta-45 to beta-46. I'll try a couple things on my side and post a reproduction as you advise if I can't resolve it, thanks.