jdorn / json-editor

JSON Schema Based Editor
MIT License
5.81k stars 1.08k forks source link

label placement error on checkbox when theme is compact #541

Open boblannon-picwell opened 8 years ago

boblannon-picwell commented 8 years ago

Example of this breaking in the demo

the root of the problem is that AbstractTheme.getFormControl doesn't account for the case where a checkbox is being used in a theme where compact = true (which means that label will be null)

working on a PR.

AlexYegupov commented 8 years ago

need fix smth like that:

--- a/dist/jsoneditor.js
+++ b/dist/jsoneditor.js
@@ -6246,7 +6246,7 @@ JSONEditor.AbstractTheme = Class.extend({
     var el = document.createElement('div');
     el.className = 'form-control';
     if(label) el.appendChild(label);
-    if(input.type === 'checkbox') {
+    if(label && input.type === 'checkbox') {
       label.insertBefore(input,label.firstChild);
     }
     else {