Combobox react widgets组合框中的键盘可访问性
我正在使用带有组标题的React Widgets组合框,无法使用键盘导航 文档页面上的第一个示例有一个可通过键盘访问的下拉列表(向上/向下箭头键),但我看不到它的源代码,并且它没有使用组标题: 该页后面的示例显示了无法通过键盘访问的源代码 我已经搜索过了,但没有找到任何示例代码来显示如何在react widgets组合框上启用键盘可访问性 这是我的密码:Combobox react widgets组合框中的键盘可访问性,combobox,accessibility,react-widgets,Combobox,Accessibility,React Widgets,我正在使用带有组标题的React Widgets组合框,无法使用键盘导航 文档页面上的第一个示例有一个可通过键盘访问的下拉列表(向上/向下箭头键),但我看不到它的源代码,并且它没有使用组标题: 该页后面的示例显示了无法通过键盘访问的源代码 我已经搜索过了,但没有找到任何示例代码来显示如何在react widgets组合框上启用键盘可访问性 这是我的密码: const GroupHeading = ({ item }) => { switch (item) { ca
const GroupHeading = ({ item }) => {
switch (item) {
case 'group 1':
return <span>Group 1</span>;
case 'group 2':
return <span>Group 2</span>;
default:
return null;
}
};
const ComboboxItem = ({ item }) => {
return (
<span className="combobox-dropdown">
<span className="item">{item.name}</span>
</span>
);
<Combobox
name={widgetId}
id={widgetId}
data={data}
defaultValue={defaultValue}
minLength={2}
filter="contains"
groupComponent={GroupHeading}
groupBy={item => item.type}
valueField="id"
textField="name"
itemComponent={ComboboxItem}
placeholder="Enter search text"
onChange={param => onChange(param, widgetId)}
onSelect={param => onSelect(param, widgetId)}
inputProps={inputProps}
autoFocus
/>
constgroupheading=({item})=>{
开关(项目){
个案"第一组":
返回组1;
个案"第二组":
返回组2;
违约:
返回null;
}
};
常量ComboboxItem=({item})=>{
返回(
{item.name}
);
item.type}
valueField=“id”
textField=“名称”
itemComponent={ComboboxItem}
占位符=“输入搜索文本”
onChange={param=>onChange(param,widgetId)}
onSelect={param=>onSelect(param,widgetId)}
inputProps={inputProps}
自动对焦
/>
有谁能说一下如何允许用户用键盘选择下拉项吗?谢谢 我想出来了!我的数据数组中的两个选项对象错误地具有相同的id。键盘导航必须通过选中valueField来工作,并且必须是唯一的 这类事情在事后看来似乎很明显,但当你有新的东西时,很容易错过