react-select2-wrapper icon indicating copy to clipboard operation
react-select2-wrapper copied to clipboard

Placeholder on multiple: false fields is not shown

Open lkacenja opened this issue 9 years ago • 1 comments

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);

lkacenja avatar Jun 23 '16 20:06 lkacenja

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.

cooperka avatar Mar 15 '19 16:03 cooperka