Given a construct like this
const editor = new JSONEditor(element, {
schema: {
type: "object",
properties: {
field1: {
type: "string"
},
field2: {
type: "string"
}
}
},
startval: {
field1: "value 1",
field2: "value 2"
}
});
const button = document.createElement("button");
button.type = "button";
button.textContent = "Delete field2";
button.onclick = () => {
const fieldEditor = editor.getEditor("root.field2");
fieldEditor.destroy();
};
const div = document.createElement("div");
div.appendChild(div);
document.body.appendChild(div);
After click on "Delete field2" the field editor is removed from the GUI and the core editor, however the parent editor still has "fieled2" in its editors list, this causes exceptions upon any subsequent action (like modifying the remaining field f.i.).
Applicable workaround is deleting child editor manually from its parent like this
button.onclick = () => {
const fieldEditor = editor.getEditor("root.field2");
delete fieldEditor.parent.editors[fieldEditor.key];
fieldEditor.destroy();
};
Such clean-up should be responsiblity of AbstractEditor.destroy.
Given a construct like this
After click on "Delete field2" the field editor is removed from the GUI and the core editor, however the parent editor still has "fieled2" in its editors list, this causes exceptions upon any subsequent action (like modifying the remaining field f.i.).
Applicable workaround is deleting child editor manually from its parent like this
Such clean-up should be responsiblity of
AbstractEditor.destroy.