hoist-react
hoist-react copied to clipboard
Select with `enableMulti: true` should have option to emit `[]` as value when empty
Currently our select
input emits null
when empty, as is standard. However when enableMulti
is true, it might be more natural / expect (or even required by APIs) to emit []
when empty, so you are always dealing with the bound value as a collection.
This could be an opt-in feature to avoid breaking any existing usages, and to maintain the default behavior of empty === null.
I'm thinking that a new emptyValue
prop on select
might be the most generally useful. Default would be null
.
We could allow the developer to set any value they wish, regardless of the enableMulti
setting. In the prop's doc comment we could clarify that the primary / expected use case is to set it to []
for multi-selects where that is desired, but perhaps there would be some app-specific use for setting it to another value like false or 0.