dhis2 / ui-forms

:no_entry: [DEPRECATED] Please refer to https://github.com/dhis2/ui
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

fix: provide object as default value for singleselect #264

Closed ismay closed 4 years ago

ismay commented 4 years ago

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" 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.

ismay commented 4 years ago

Hope this will be the start of a long series of contributions 👍

Definitely 😊👍

dhis2-bot commented 4 years ago

:tada: This PR is included in version 1.0.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: