wip(forms): Try to be smart and use MultiChoice only for short labels

This commit is contained in:
Yohan Boniface 2024-02-29 19:17:36 +01:00
parent a7a854dd74
commit 4cdf682706

View file

@ -999,7 +999,10 @@ U.FormBuilder = L.FormBuilder.extend({
if (schema.step) schema.handler = 'Range' if (schema.step) schema.handler = 'Range'
else schema.handler = 'IntInput' else schema.handler = 'IntInput'
} else if (schema.choices) { } else if (schema.choices) {
if (schema.choices.length <= 5) { const text_length = schema.choices.reduce((acc, [value, label]) => acc + label.length, 0)
// Try to be smart and use MultiChoice only
// for choices where labels are shorts…
if (text_length < 40) {
schema.handler = 'MultiChoice' schema.handler = 'MultiChoice'
} else { } else {
schema.handler = 'Select' schema.handler = 'Select'