vuetify-jsonschema-form icon indicating copy to clipboard operation
vuetify-jsonschema-form copied to clipboard

Not working when schema and data changes

Open flaviocordova opened this issue 5 years ago • 10 comments

if you change both schema and data, fields are rendered properly but data is not shown (all fields show empty value).

Check this codepen: https://codepen.io/fcordova/pen/GRgZmRz

If you first click 'LOAD DATA 1' form is shown perfectly, but once you click 'form data 2' the form is rendered empty. If you reload the page and begin with data 2, it's also rendered fine but then data 1 can't be rendered anymore.

flaviocordova avatar Dec 10 '19 21:12 flaviocordova

same issue. have you solve the problem? @flaviocordova

nickjfree avatar Jan 26 '20 13:01 nickjfree

Nope, I guess it'll require a fix, no?

flaviocordova avatar Feb 12 '20 19:02 flaviocordova

I will try to make it work in upcoming major version. But I don't want to spend too much time on current version. Can this be solved with a v-if to destroy / recreate the form when the schema changes ?

albanm avatar Feb 12 '20 19:02 albanm

Recreating the form with v-if works.:)

nickjfree avatar Feb 13 '20 00:02 nickjfree

Recreating the form with v-if works.:)

@nickjfree could you update Codepen with your solutions?

OdiljonQurbon avatar Feb 13 '20 14:02 OdiljonQurbon

https://codepen.io/nickjfree/pen/gOpPXpj

nickjfree avatar Feb 14 '20 04:02 nickjfree

https://codepen.io/nickjfree/pen/gOpPXpj

Cool, thank you @nickjfree !

OdiljonQurbon avatar Feb 14 '20 04:02 OdiljonQurbon

@nickjfree if I use your workaround but mix it with a keep-alive component, the result is really bad performance (event binding memory leak maybe?) and strange things appear to happen with inputs where the input loses focus after I type one time.

There's a chance this is specific to my code but I'm wondering if there is a better way for this to be done? Maybe for the form to properly watch the model and update accordingly.

I will need this functionality to behave properly in the relatively near future so if there is no additional work-around or work being done here, I may start on a PR, although I may need a nudge in the right direction from you @albanm.

ghost avatar Jul 10 '20 20:07 ghost

I tried to look into this a little, but I didn't reach a working solution and reactivity subtleties were giving me headaches. I think even if I were to improve things, perfectly reacting to external changes of both schema and model will never be guaranteed by this library. I strongly suggest working on your side.

albanm avatar Jul 28 '20 13:07 albanm

I had very similar issue. When the whole value of model is replaced, the form is not updated. I wanted to cycle through a list of forms by replacing the v-model - it did not work.

The trick with v-if works for me, too.

Instead of v-if it is possible to use :key either on the component or on the form.

<v-jsf :key="nextkey">

This way it is not needed to use this $nextTick function.

uaru avatar Jan 30 '23 07:01 uaru