So, initially I wanted to address the array that was being passed to the SingleSelect as the selected prop, where it expects an object. I thought we could omit the defaults, since the Selects set their own defaults, but input.value is an empty string initially, and that overrides the defaultProp and crashes the Select.
So I've added comments describing why we do this. It also seems like there's a bug in final form, because setting type="select" and multiple on a Field should ensure that the initial value is an empty array: https://github.com/final-form/react-final-form/blob/d90e418d5ceaa4833d19183ffeea9e5067610f96/src/Field.test.js#L371. But it looks like the value they're testing for is ''? From trying it out on codesandbox, it really does seem to be an empty string instead of []. So what we're doing also addresses that.
Closes #263
So, initially I wanted to address the array that was being passed to the SingleSelect as the selected prop, where it expects an object. I thought we could omit the defaults, since the Selects set their own defaults, but input.value is an empty string initially, and that overrides the defaultProp and crashes the Select.
So I've added comments describing why we do this. It also seems like there's a bug in final form, because setting
type="select"
andmultiple
on a Field should ensure that the initial value is an empty array: https://github.com/final-form/react-final-form/blob/d90e418d5ceaa4833d19183ffeea9e5067610f96/src/Field.test.js#L371. But it looks like the value they're testing for is''
? From trying it out on codesandbox, it really does seem to be an empty string instead of[]
. So what we're doing also addresses that.