Skip to content

Commit

Permalink
feat(component): add suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Navarro committed May 11, 2022
1 parent 9e1cf2b commit a1cfc6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ export const MultiSelect = typedMemo(
setInputValue('');
}, [selectedOptions]);

const getFirstMatchingOptionIndex = (filteredOptions: (SelectOption<T> | SelectAction)[]) => {
return filteredOptions.findIndex((option) => !option.disabled);
};

const handleSetInputValue = ({
inputValue,
isOpen,
Expand All @@ -113,10 +117,6 @@ export const MultiSelect = typedMemo(
);
};

const getFirstMatchingOptionIndex = (filteredOptions: (SelectOption<T> | SelectAction)[]) => {
return filteredOptions.findIndex((option) => !option.disabled);
};

const handleOnIsOpenChange = ({ isOpen }: Partial<UseComboboxState<SelectOption<T> | SelectAction | null>>) => {
if (filterable && !isOpen) {
// Reset the items if filtered
Expand Down
8 changes: 4 additions & 4 deletions packages/big-design/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export const Select = typedMemo(
// Need to set select options if options prop changes
useEffect(() => setFilteredOptions(flattenedOptions), [flattenedOptions]);

const getFirstMatchingOptionIndex = (filteredOptions: (SelectOption<T> | SelectAction)[]) => {
return filteredOptions.findIndex((option) => !option.disabled);
};

const handleOnSelectedItemChange = (changes: Partial<UseComboboxState<SelectOption<T> | SelectAction | null>>) => {
if (action && changes.selectedItem && changes.selectedItem.content === action.content) {
action.onActionClick(inputValue || null);
Expand Down Expand Up @@ -120,10 +124,6 @@ export const Select = typedMemo(
);
};

const getFirstMatchingOptionIndex = (filteredOptions: (SelectOption<T> | SelectAction)[]) => {
return filteredOptions.findIndex((option) => !option.disabled);
};

const handleOnIsOpenChange = ({ isOpen }: Partial<UseComboboxState<SelectOption<T> | SelectAction | null>>) => {
if (filterable && !isOpen) {
// Reset the options when the List is closed
Expand Down

0 comments on commit a1cfc6f

Please sign in to comment.