react-select icon indicating copy to clipboard operation
react-select copied to clipboard

Weird behaviour with Select.Async and loadOptions

Open milushov opened this issue 9 years ago • 1 comments

Sorry, that's a question actually

I have following code and very weird behavior (on the gif below). The question is -- what I'm doing wrong? Why options not shown immediately after the getOptions func done? Why they shown only after the click outside? That's super confusing.. I need your help guys!

[deleted gif]

getOptions = (value) =>
  return Promise.resolve({options: []}) unless value
  api.geocoder(value).then (data) =>
    countries = [
      {value: 'A', label: 'A'}
      {value: 'B', label: 'B'}
    ]
    console.info(countries)
    {options: countries}

<Select.Async
  className="ads-filter__select"
  value={@props.country_code}
  onChange={(option) => @props.onChange('country_code', option)}
  clearable={false}
  placeholder={I18n.t('ads.country')}
  loadOptions={getOptions}
/>

milushov avatar Aug 04 '17 11:08 milushov

filterOptionAsync(option) {
  // Make logic here, just return true for test
  return true
}

<Select.Async
  className="ads-filter__select"
  value={@props.country_code}
  onChange={(option) => @props.onChange('country_code', option)}
  clearable={false}
  placeholder={I18n.t('ads.country')}
  loadOptions={getOptions}
  // Add props filterOption
  filterOption={this.filterOptionAsync}
/>

Read about this option

adrianojdesouza avatar Aug 09 '17 15:08 adrianojdesouza