简体   繁体   中英

React-select sometimes doesn't display the options in the dropdown menu on async search

strange one here. When using React-Select v1.0.0rc (although the bug occurs with all v1.x) using it in Async mode to search an API, sometimes the options will not show in the dropdown menu. There seems to be no reason for why this happens, but it happens with certain search queries and not others.

Eg coconut works but coconut oil doesnt, even though both return similar results.

The strange thing is that using the React chrome developer tools I can see that the options are set on the state of the Select, but they just don't appear. Also, if I click off the react-select, then click back on it, the results appear (tested in firefox and chrome). Here is my code and a few screenshots to illustrate

<Select.Async name={ this.generateName('ingredient_id')}
          loadOptions={this.getIngredients}
          className="admin-meal-ingredient-search-select"
          autoload={false}
          cache={false}
          multi={false}
          value={this.props.ingredient}
          onChange={this.props.handleIngredientChange}
          placeholder="Search for ingredient" />

Here you can see I have typed something in but no results are coming up

搜索词不显示图像

Here you can see the results in the React inspector in the options array

在此处输入图片说明

When I click away then click back on the box, the options are

appearing

点击离开然后回来,他们在那里

我正在使用"react-select": "^3.0.4",并且不得不添加filterOption={false}道具。

我找到了一个解决方案,那就是设置filterOptions= {false}

是的,它是filterOption ={false},输入时要小心,这样你就不会想知道为什么它不适合你:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM