[SOLVED] Custom JSON editor parent doesn't send "valueChanged" message back to editor

I have…

  • [ ] Checked the logs and have uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [x] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

I am using the custom editor documentation here
When I call editor.valueChanged({[new json]}) to inform Squidex that the value has changed, the value is updated in backend, but the editor-sdk never receives the valueChanged event (and so my onValueChanged() callback is never called (after initially being called on first load).

It’s weird because the formValueChanged message is successfully seen by the editor-sdk when I call editor.valueChanged, but the valueChanged message is never seen.

Expected behavior

After calling editor.valueChanged, editor should receive valueChanged message from parent as an acknowledgement that the value was successfully changed.

Minimal reproduction of the problem

Set up a custom editor on a JSON field, do var editor = new SquidexFormField(), setup an onValueChanged callback with simple console log, call editor.valueChanged({}). You will see that callback is never called.

Environment

  • [ ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [x] Cloud version

Version: Current

Browser:

  • [x] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

The custom editors are built around angular forms and this is just not how angular forms works. The reason is that it is not necessary and that you can easily end in an infinite loop then.

Why do you need it?

Ah ok. I am writing a custom editor in React, and I wanted to use editor.getValue() as my source of truth. Currently, if I call editor.valueChanged and then at a later time try editor.getValue(), the value is out of date because of how the editor-sdk works. I can find another solution, but this feels weird to me. Especially since editor.getFormValue() returns the updated value among the rest of the form data.

I have also run into another bug (let me know if I should file a separate report): my custom editor is for a JSON field within an array. Usually, editor.getFormValue() returns the whole form data. But immediately after a save, editor.getFormValue() only returns the data from the array.

Are you using the latest version? It sounds like an old bug that could have been fixed. The getValue() thing is also another story, I think this should be fixed, I just want to avoid creating this loop of events.

Hi, I have fixed that and also pushed a test editor to log status changes:

It will be available as soon as it is deployed:
https://cloud.squidex.io/scripts/simple-log.html

I have deployed that.