Repository: vazco/uniforms (ts)

Issue:
SimpleSchema: minCount arrays with options set empty checkboxes 
<!--
  Before you open an issue, please check if a similar one already exists or has been closed before.
  We will be grateful for using our reproduction sandbox available at
  https://codesandbox.io/s/github/vazco/uniforms/tree/master/reproductions
  whenever a code sample is presented for debugging purposes.
-->

When defining an `array` schema with `minCount` and `options`, `AutoForm` renders the field with empty `checkboxes`.
Consider the following schema:
```
members: {
    type: Array,
    minCount: 2, 
  },
  "members.$": {
    type: String,
    uniforms: {
       options: [{label: "Label1", value: "val1"}, {label: "Label2", value: "val2"}]
    }
}
```
On the playground, this will result in a `SelectField` with **2 empty checkboxes**. More over, no validation will be apply even taught no options is choosen when submitting the form. Meaning the array field is prepopulated with null values that are consider as valid from the schema.

1. The members' array should not be populated with null values when using `minCount`. It should be empty and validated.
2. The UI should not display empty checkboxes. Just like with null values, it should be empty and validated.

Pull request:
Added filtering undefined values in array of SelectField (fixes #691).
This PR introduces filtering `undefined` values inside `SelectField` to fix empty boxes.

Patch:
diff --git a/packages/uniforms-antd/src/SelectField.tsx b/packages/uniforms-antd/src/SelectField.tsx
index b158ee47..77913add 100644
--- a/packages/uniforms-antd/src/SelectField.tsx
+++ b/packages/uniforms-antd/src/SelectField.tsx
@@ -39,7 +39,13 @@ const renderSelect = props => (
     onChange={value => props.onChange(value)}
     placeholder={props.placeholder}
     ref={props.inputRef}
-    value={props.value || (props.fieldType === Array ? [] : undefined)}
+    value={
+      props.fieldType === Array
+        ? props.value
+          ? props.value.filter(value => value !== undefined)
+          : []
+        : props.value
+    }
     {...filterDOMProps(props)}
   >
     {props.allowedValues.map(value => (


Test patch:
diff --git a/packages/uniforms-antd/__tests__/SelectField.tsx b/packages/uniforms-antd/__tests__/SelectField.tsx
index 2566a4da..3ee8f773 100644
--- a/packages/uniforms-antd/__tests__/SelectField.tsx
+++ b/packages/uniforms-antd/__tests__/SelectField.tsx
@@ -177,6 +177,21 @@ test('<SelectField> - renders a select which correctly reacts on change (array)'
   expect(onChange).toHaveBeenLastCalledWith('x', ['b']);
 });
 
+test('<SelectField> - renders a select (undefined values)', () => {
+  const element = <SelectField name="x" value={[undefined, 'a', undefined]} />;
+  const wrapper = mount(
+    element,
+    createContext({
+      x: { type: Array },
+      'x.$': { type: String, allowedValues: ['a', 'b'] },
+    }),
+  );
+
+  expect(wrapper.find(Select)).toHaveLength(1);
+  expect(wrapper.find(Select).prop('value')).not.toContain(undefined);
+  expect(wrapper.find(Select).prop('value')).toContain('a');
+});
+
 test('<SelectField> - renders a select which correctly reacts on change (empty)', () => {
   const onChange = jest.fn();