我正在使用带有组标题的 React Widgets 组合框,但我无法使用键盘导航。
文档页面上的第一个示例有一个可通过键盘访问的下拉菜单(向上/向下箭头键),但我看不到它的源代码,并且它不使用组标题:
https://jquense.github.io/react-widgets/api/Combobox/
该页面上显示源代码的后面示例无法通过键盘访问。
我已经搜索但没有找到任何示例代码,显示如何在反应小部件组合框上启用键盘可访问性。
这是我的代码:
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
/>
谁能说如何允许用户使用键盘选择下拉项目?谢谢!