Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const SelectBasic: React.FunctionComponent = () => {
// When no options are found after filtering, display 'No results found'
if (!newSelectOptions.length) {
newSelectOptions = [
{ isDisabled: false, children: `No results found for "${filterValue}"`, value: 'no results' }
{ isAriaDisabled: true, children: `No results found for "${filterValue}"`, value: 'no results' }
];
}

Expand All @@ -59,6 +59,14 @@ export const SelectBasic: React.FunctionComponent = () => {
setFocusedItemIndex(null);
}, [filterValue]);

const onInputClick = () => {
if (inputValue) {
setIsOpen(true);
} else {
setIsOpen(!isOpen);
}
};

const onToggleClick = () => {
setIsOpen(!isOpen);
};
Expand All @@ -80,6 +88,10 @@ export const SelectBasic: React.FunctionComponent = () => {
const onTextInputChange = (_event: React.FormEvent<HTMLInputElement>, value: string) => {
setInputValue(value);
setFilterValue(value);

if (value !== selected) {
setSelected('');
}
};

const handleMenuArrowKeys = (key: string) => {
Expand Down Expand Up @@ -132,6 +144,7 @@ export const SelectBasic: React.FunctionComponent = () => {
case 'Tab':
case 'Escape':
setIsOpen(false);
setFocusedItemIndex(null);
setActiveItem(null);
break;
case 'ArrowUp':
Expand All @@ -147,7 +160,7 @@ export const SelectBasic: React.FunctionComponent = () => {
<TextInputGroup isPlain>
<TextInputGroupMain
value={inputValue}
onClick={onToggleClick}
onClick={onInputClick}
onChange={onTextInputChange}
onKeyDown={onInputKeyDown}
id="typeahead-select-input"
Expand Down Expand Up @@ -188,6 +201,8 @@ export const SelectBasic: React.FunctionComponent = () => {
onSelect={onSelect}
onOpenChange={() => {
setIsOpen(false);
setFocusedItemIndex(null);
setActiveItem(null);
}}
toggle={toggle}
>
Expand Down