Closed Cheprod closed 5 years ago
Seems to have something to do with uniqueItems
.
If you set uniqueItems": false
, the table controls will show up.
Yes, I did't notice this detail ;)
It looks like that nothing is done if uniqueItems is set to true in this section of code :
// Specialized editors for arrays of strings
JSONEditor.defaults.resolvers.unshift(function(schema) {
if(schema.type === "array" && schema.items && !(Array.isArray(schema.items)) && schema.uniqueItems && ['string','number','integer'].indexOf(schema.items.type) >= 0) {
// if 'selectize' enabled it is expected to be selectized control
if (JSONEditor.plugins.selectize.enable) {
return 'arraySelectize';
}
// otherwise it is select
else {
return 'multiselect';
}
}
});
I think it's the correct behavior in 1.4.0-beta.0
It makes sense that uniqueItems
has to be false
when using array/table editor as source. As you can't ensure that the user doesn't add a duplicate value.
This feature works well in the 1.3.5 with array of string :
@Cheprod I think I got it figured out, and will submit a PR with fix in the develop/2.x branch (That's the only branch I'll submit PRs to.) In the develop/2.x branch the Select2 plugin have been moved to separate editor, so there's an additional check.
But basically the fix just removes the return 'multiselect'
. Then it works with both uniqueItems
true or false.
Fix have been added to the develop/2.x branch.
General information
Expected behavior
Normal behaviour with add/remove button to add/remove string value in the array. Work well in version 1.3.5
Actual behavior
Just a blank field
Steps to reproduce the behavior
Direct link to example: https://json-editor.github.io/json-editor/?schema=N4IgLglmA2CmIC4QDMJwCIEMyYEqwGMB7AJwBNYSQAaECgZwJIgAdIiA7REAYU9QDmAVxLYInAAQBlAgAtYAW0wTkpCQDE0sLDnzFylGuACeLeEiIAjAFaEwRliSJmSkWPUSgh9WAFUAKjyedO5MrOxcSACSHGQQAI5CsBL0EBKSQpDQED4S0ADk8iLJATwSLEQiecmQCu44CixGYKbmIJZERHCYXLQUyJhC0PYIYCRJAL603n6BmnAAcph1wQxhbOKRIDFxicmp6RwSmWg5yQVFJCWB5ZUk1RIcRAoKAJcPqHIQhrQtZtwdLqwHpGfqDYaIMaTX4QOr0BosdSkJQjUBrZgbTjcJEkFESMhCCS1erLFgSAAUsAAHhIEBIAKRkAD09IULIAmgyABIIekAWV5UgAlAA6CQAGUwOXo7wAbhAKLcqidsj57nAVMjsOVMPcyK8BpkKTi8VEpAB5AAcADYAAwARlFzVa3HhzA4AlBsENEKQ9PZICm4EwAnoSxWCDRoQxEW44pyYGSDEez3o+JqIbTAAOJK8wld8T00xrPrJvnqk5wOK93GKpGlBgQhEccKHHvl6ikWHmIKhXtQJGg02rOGAiZU03nmGA02Qix8IF9KCLnf8kLrRMZmlA4Nx/JmJP4IEZVLjsNwcJZd7RnBEPJG6DlMFfYAB9YjQaCYFg+SHjWC0BumDGO+o5ONA9CvmAzh/tCIBQIo96gH8bRuhAHrbjAbT7qGga0Ao6FRImCj3ra0wcAkSREYhsGwEGADWsCwIiWj0OgIjoQIMRSIQqzRuEmzcAszyWAWio+MQsTuOUsCxD0Y5wPQewQRIklqrKlDVGmpblrOlYcNWtYSlK9BqhIOa2jJuKwGOiocMkLCYMOQgsI4sKaYpKiLmWlD0Cuvwukg6GJgIPwgARFEKEICiILaQbEC8UBSHcBCwOG5hRowMaCUgwkKKpzwsHAtmEgoRAEhqZD5EQACf5ROPKskKckCUEfYAVriAaEYRMQZXIkEBXGQiAANogDMpRGBNcxaOlzSZnNtCMcx8zuOx7pcRwPEEEYrVJSlaXLPAAC6tCnii3AENgsACKQ3weLQlhOYuPDXbdJDGEeWHcAACu6BCsJg0CBkAA==&value=N4IgrgzgpgqgKgYRALgC4CcxQDTmvBAMQEsAbKAOQEMBbKFDLXVKgcwmrpQG0BdXANZQoABxLkIAETDpiAO1YBJOQGUoAYxQAGXOoD2NGsVQq9M9ZVr1kIEAF8gA&lib_switcher=&prompt_before_delete&upload=function(a,b,c){console.log(%22Upload%20handler%20required%20for%20upload%20editor%22)}&theme=foundation5&iconlib=fontawesome4&object_layout=normal&show_errors=interaction