我正在使用一个搜索功能,它会在您键入时对选项进行重新排序。React-select将保持最初第一个选项的焦点,即使该选项随后移动到列表中的不同位置。所以当你输入的时候,焦点会在屏幕上上下跳动。我希望focussed选项保留为键入时的第一个选项。
有没有办法控制哪个选项被聚焦?
发布于 2019-03-09 23:07:53
将随机生成的"value“属性添加到传递给react-select的选项中,似乎就创建了我想要的功能。
// code for loadOptions prop in react-select's AsyncCreatable
import uniq from "uniqid";
// code to get search results
const resultsWithRandomValue = results.map(r => ({ ...r.item, value: uniq() }));这并不理想,但其他任何东西都需要对react-select进行更改,而且我不确定通常情况下有多少需要这种行为。
https://stackoverflow.com/questions/54958502
复制相似问题