rkit / react-select2-wrapper

Wrapper for Select2
MIT License
163 stars 97 forks source link

Selects first option automatically #53

Closed farhan687 closed 8 years ago

farhan687 commented 8 years ago

I am using tags true when I try to create a new tag, Select2 automatically choose the first option though it is not executing onchange event but it should be empty if I didn't select anything already.

animation 1

other than this wrapper works pretty well, thanks a lot for creating such wrapper, it saved my lot of time.

farhan687 commented 8 years ago

Code snippet:

<Select2
                multiple={false}
                data={ ['test', 'test1', 'cool'] }
                value={this.state.selectedType}
                options={{
                  placeholder: 'Choose or create a new type',
                  tags: {true}
                }}
                onChange={this.onTypeSelection}
              />
rkit commented 8 years ago

thanks a lot for creating such wrapper, it saved my lot of time

You are welcome!

Please try the following code:

<Select2
  multiple={false}
  data={ ['', 'test', 'test1', 'cool'] }
  value={this.state.selectedType}
  options={{
    placeholder: 'Choose or create a new type',
    tags: true,
    allowClear: true,
  }}
  onChange={this.onTypeSelection}
/>
farhan687 commented 8 years ago

Thanks @rkit, it works.