-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
@jdorn: Thanks for merging #461 -- it's something that I also needed. I am noticing one problem though, and I'm not sure the best way to go about fixing it. When the empty value is selected, it removes the property from the object entirely. So for the demo on http://jeremydorn.com/json-editor/, if you select the empty option in the gender dropdown, the gender property will no longer show up in the json panel on the right side of the page. If you then click "Update Form", the gender dropdown will be removed from the form.
This seems like odd behavior to me. I think a common use-case for the json-editor is to be able to view an object, make changes, save, and be able to repeat that process as many times as needed. If someone selects the empty option in a dropdown, but then wants to later go back and make a selection, I believe the dropdown should still exist.
One simple (though possibly hacky) fix would be to switch the underlying empty value from undefined to an empty string. That would require changing those few undefined values in PR #461, and also modifying the enum validator to not mark empty strings as invalid. Though I think the real underlying problem may be the fact that when a property of an object does not exist, yet does exist in the schema, it is not currently rendered. This is the case with other types as well: for example, on the demo site, if I edit the json object and remove the name property, it is not rendered, even though it exists in the schema.
I'd appreciate your thoughts on this, and I'd be happy to help out with a solution.
@lepinay: Looping you in as well, as you may have given some thought to this.