Reproduction Steps: 1. Load up https://btheado.github.io/jsoneditor.html 2. Go to the "*Degenerate case: no schema specified*" example 3. Change the root to "array" and add 1 item. 4. Set the first array item to type "boolean". 5. Set the first array item to type "number". 6. Set the first array item to type "boolean".
Observed Results: Step 4: The schema at the bottom reads `[false]`, but the UI item renders `null`. Step 5: The schema at the bottom reads `[""]`, and the UI item renders correctly. Step 6: The schema at the bottom reads `[false]`, but the UI item renders `null`. Best I could tell from the symptoms, there is something going on where the editor widget confirms the edit and writes the JSON. This triggers TW's refresh mechanism. When it gets to your `JSONEditorWidget.prototype.refresh` function it detects that the SCHEMA value of the options has changed, which triggers `this.refreshSelf();`. This appears to trigger TW's refresh cycle again, causing the selected option to be written - but the UI is using the previous version of the schema. Really weird case. I'm going to read through the guts of JSONEditor's core.js file and also the "./editors/*" functions to see if we can get it to spawn native TW input widgets (which will automatically handle writing the data to the target for you with the TW input mechanism), and disable JSONEditor's internal refresh mechanism. We'll see how that goes... Best, Joshua F On Saturday, March 16, 2019 at 1:47:12 PM UTC-7, Brian Theado wrote: > > Joshua, > > > there is a race condition bug in how the jsoneditor manipulated the DOM > vs how TW manipulates the DOM > > Could you share the details on that? > > That was the first TW plugin I wrote. Being a little new I found it > annoying not to be able to use a field in the same tiddler to store the > output json (in fact if no text reference is passed in, the default is a > field on the current widget) and so I tried to code around it and make it > work for that case. I think that was a mistake and I could easily see it > causing some kind of problems. Could that be the source of your issue? > > Brian > > On Fri, Mar 15, 2019 at 3:17 PM Joshua Fontany <[email protected] > <javascript:>> wrote: > >> I'm experimenting with rendering UI by setting up JSON Schemas. There was >> an old TW port of one of the earlier versions of this project, and I was >> able to import the currently maintained module into that plugin. >> >> Than I discovered that there is a race condition bug in how the >> jsoneditor manipulated the DOM vs how TW manipulates the DOM. I scanned >> through the docs and sourcecode a while, and it seems like they have built >> this modularly enough that I can change the "rendering engine" file for >> each Input type and make them render native TW widgets. I will have to cut >> out all of json-editor's native messaging code and just rely on the TW >> refresh and get/setTextReference functions. >> >> This seems doable, but wanted to see if anyone has run into any 'gotchas' >> or roadblocks in similar cases... >> >> origin: https://github.com/json-editor/json-editor >> >> previous TW plugin: https://github.com/btheado/jsoneditor >> >> current TW plugin (broken, does not push json updates back to TW): >> https://github.com/joshuafontany/TW5-jsoneditor >> >> current Example wiki: >> https://joshuafontany.github.io/TW5-jsoneditor/ >> >> Best, >> >> Joshua Fontany >> >> -- >> You received this message because you are subscribed to the Google Groups >> "TiddlyWikiDev" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/tiddlywikidev. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/tiddlywikidev/65200232-3d7d-448e-a741-c3a652d60cca%40googlegroups.com >> >> <https://groups.google.com/d/msgid/tiddlywikidev/65200232-3d7d-448e-a741-c3a652d60cca%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/tiddlywikidev. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/37b00b7b-5440-43e9-beb6-f3bc9dbd85b3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
