diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 34710d5337..042bfec8ef 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -31,6 +31,7 @@ # In Javascript : - 'creme.form.Select2' now supports the lazy loading of selections : Useful in entity filter polymorphic inputs that do not know the selected options beforehand. + - Fix a conversion issue in DynamicSelect.val() for a multiple combobox with a single value Breaking changes : ------------------ diff --git a/creme/creme_core/static/creme_core/js/tests/widgets/dselect.js b/creme/creme_core/static/creme_core/js/tests/widgets/dselect.js index f69a3a5808..6b834588b4 100644 --- a/creme/creme_core/static/creme_core/js/tests/widgets/dselect.js +++ b/creme/creme_core/static/creme_core/js/tests/widgets/dselect.js @@ -850,6 +850,9 @@ QUnit.parametrize('creme.widget.DynamicSelect.val (static, multiple)', [ widget.val(3); deepEqual(['3'], widget.val()); + widget.val(5); + deepEqual(['5'], widget.val()); + widget.val(null); deepEqual([], widget.val()); diff --git a/creme/creme_core/static/creme_core/js/widgets/dselect.js b/creme/creme_core/static/creme_core/js/widgets/dselect.js index c424740e1d..d44ebbdd19 100644 --- a/creme/creme_core/static/creme_core/js/widgets/dselect.js +++ b/creme/creme_core/static/creme_core/js/widgets/dselect.js @@ -325,9 +325,11 @@ creme.widget.DynamicSelect = creme.widget.declare('ui-creme-dselect', { var values = value.split(','); selected = isJSON ? creme.utils.JSON.clean(value, values) : values; } else { - /* Can be an Object or an Array -> convert to Array */ - selected = Array.isArray(value) ? value : [value]; + selected = value; } + + /* Can be an Object or an Array -> convert to Array */ + selected = Array.isArray(selected) ? selected : [selected]; } else { selected = [value]; }