Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when schema changes, fields are not updated #12

Open
shagabay opened this issue Mar 21, 2018 · 2 comments
Open

when schema changes, fields are not updated #12

shagabay opened this issue Mar 21, 2018 · 2 comments

Comments

@shagabay
Copy link

hi,

thanks for your support !

not sure if this is a bug in the editor itself or in the component, but when i change some field name, the changes are not reflected in the editor:

  • it seems like the "required" part is updated
  • but the field name itself is not. the result is that the field is not considered required anymore

you can replicate with the attached example, click on 'onClick1' and then 'onClick2'. the field 'firstName' is renamed in the schema by the code (see app.vue) to 'firstName2', but you can see that it's not reflected in the editor.

a workaround is also good at this point...

thanks
sharon
example.zip

@plantain-00
Copy link
Owner

It is kind of buggy when the schema is changed after initialization finished.
I found it is difficult to fix it.
My use case is when a field is like true, field firstName exists, when field is false, fleld firstName2 exists and firstName disappear, I can use the non-standard requiredWhen (https://github.com/plantain-00/schema-based-json-editor#features ; the online demo shows it too) to do this.

@shagabay
Copy link
Author

another solution i've found:

<json-editor
v-if="visible"
// USING V-IF TO TOGGLE VISIBILITY OF THE EDITOR, HENCE CREATE/DESTROY
:schema="schema"
:initial-value="value"
theme="bootstrap4"
icon="fontawesome4">

...

data () {
  return {
    visible: true,

...

  onClick: function (event) {
    this.schema = JSON.parse(this.editorText)
    this.visible = false
    setTimeout(() => this.visible = true, 50);
    // TOGGLING VISIBILITY WITHOUT A TIMEOUT DIDN'T WORK
  }

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

No branches or pull requests

2 participants