rkit / react-select2-wrapper

Wrapper for Select2
MIT License
163 stars 97 forks source link

Placeholder on multiple: false fields is not shown #37

Open lkacenja opened 8 years ago

lkacenja commented 8 years ago

Thanks for the component. I could be completely missing something obvious here. In case someone else ran into this, I wanted to document a solution. It is a fairly documented case that select2 requires an empty <option> for placeholders to show up on single value fields. This seems to still be the case. I was able to get the placeholder to show up by adding an empty option to the data prop. Something like:

var data = [];
var empty = {id: null, text: null};
data.unshift(empty);
cooperka commented 5 years ago

This is a few years old now and the suggested workaround did not work for me: the empty option was ignored and not rendered.

I ended up using allowClear: true with an onUnselect callback.