我们有一个用例,我们必须根据选择的选项数量为多选下拉列表呈现多个不同版本的值容器。下面的代码片段显示了其中一种情况。这个的另一个版本呈现一个<SingleValue />而不是占位符。
<ValueContainer {...props}>
<Placeholder {...props}>
{!props.selectProps.inputValue && `${length} selected`}
</Placeholder>
{children[1]}
</ValueContainer>
Run Code Online (Sandbox Code Playgroud)
这似乎运行良好,但是我们在选择其中一个选项时会丢失键盘导航。我是否忘记传递某些道具或裁判?
可以在此处找到自定义 ValueContainers 的键盘导航示例:https ://codesandbox.io/s/rjvkzk1nn?from-embed