From 4cdf682706d832cdb1c6974cd463f173fc1094b8 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 29 Feb 2024 19:17:36 +0100 Subject: [PATCH] wip(forms): Try to be smart and use MultiChoice only for short labels --- umap/static/umap/js/umap.forms.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/umap.forms.js b/umap/static/umap/js/umap.forms.js index 919711eb..ab960169 100644 --- a/umap/static/umap/js/umap.forms.js +++ b/umap/static/umap/js/umap.forms.js @@ -999,7 +999,10 @@ U.FormBuilder = L.FormBuilder.extend({ if (schema.step) schema.handler = 'Range' else schema.handler = 'IntInput' } 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' } else { schema.handler = 'Select'