Skip to content

Commit f4b65c4

Browse files
authored
Allow for keyboard-only selection of create option (#593)
1 parent e1e03be commit f4b65c4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/select-panel/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ const SelectPanel = () => {
174174
getFilteredOptions().then(setFilteredOptions);
175175
}, [searchTextForFilter, options]);
176176

177+
const creationRef: any = useRef()
178+
useKey([KEY.ENTER], handleOnCreateOption, { target: creationRef });
179+
177180
return (
178181
<div className="select-panel" role="listbox" ref={listRef}>
179182
{!disableSearch && (
@@ -220,7 +223,7 @@ const SelectPanel = () => {
220223
onClick={(_e, index) => handleItemClicked(index)}
221224
/>
222225
) : isCreatable ? (
223-
<li onClick={handleOnCreateOption} className="select-item creatable">
226+
<li onClick={handleOnCreateOption} className="select-item creatable" tabIndex={skipIndex === 1 ? 0 : 1} ref={creationRef}>
224227
{`${t("create")} "${searchText}"`}
225228
</li>
226229
) : (

0 commit comments

Comments
 (0)