diff --git a/ipywidgets_jsonschema/form.py b/ipywidgets_jsonschema/form.py index fdf4a9f..7824625 100644 --- a/ipywidgets_jsonschema/form.py +++ b/ipywidgets_jsonschema/form.py @@ -931,12 +931,18 @@ def _resetter(): # Initially call the resetter _resetter() + def _getter(): + result = [h.getter() for h in elements[:element_size]] + if schema.get("uniqueItems", False): + result = list(set(result)) + return result + wrapped_vbox[0] = self._wrap_description( wrapped_vbox[0], schema.get("description", None) ) return self.construct_element( - getter=lambda: [h.getter() for h in elements[:element_size]], + getter=_getter, setter=_setter, resetter=_resetter, widgets=wrapped_vbox, diff --git a/tests/schemas/array-set.json b/tests/schemas/array-set.json new file mode 100644 index 0000000..676361d --- /dev/null +++ b/tests/schemas/array-set.json @@ -0,0 +1,29 @@ +{ + "default": [], + "invalid": [ + [ + "1", + "1", + "3" + ] + ], + "schema": { + "description": "Bla bla", + "items": { + "default": "foo", + "type": "string" + }, + "type": "array", + "uniqueItems": true + }, + "valid": [ + [ + "foo" + ], + [ + "1", + "2", + "3" + ] + ] +}