diff --git a/packages/frontend/src/components/shared/UserSelect/UserSelect.tsx b/packages/frontend/src/components/shared/UserSelect/UserSelect.tsx index eaae61d1..07866570 100644 --- a/packages/frontend/src/components/shared/UserSelect/UserSelect.tsx +++ b/packages/frontend/src/components/shared/UserSelect/UserSelect.tsx @@ -5,14 +5,14 @@ import React, { useEffect, } from 'react'; import { useNavigate } from 'react-router-dom'; -import { useCombobox } from 'downshift'; -import { UserSelectTheme, userSelectTheme } from './UserSelect.theme'; +import { useSelect } from 'downshift'; import { BuildingIcon, ChevronUpDown, SettingsSlidersIcon, } from 'components/shared/CustomIcon'; import { cn } from 'utils/classnames'; +import { UserSelectTheme, userSelectTheme } from './UserSelect.theme'; import { EmptyUserSelectItem, UserSelectItem } from './UserSelectItem'; export type UserSelectOption = { @@ -77,23 +77,27 @@ export const UserSelect = ({ options, value }: UserSelectProps) => { const isSelected = (item: UserSelectOption) => selectedItem?.value === item.value; - const { isOpen, getMenuProps, highlightedIndex, getItemProps, openMenu } = - useCombobox({ - items: options, - // @ts-expect-error – there are two params but we don't need the second one - isItemDisabled: (item) => item.disabled, - onSelectedItemChange: ({ selectedItem }) => { - if (selectedItem) { - console.log(selectedItem); - handleSelectedItemChange(selectedItem); - } - }, - onIsOpenChange: ({ isOpen }) => { - setDropdownOpen(isOpen ?? false); - }, - selectedItem: value || null, - itemToString: (item) => (item ? item.label : ''), - }); + const { + isOpen, + getMenuProps, + getToggleButtonProps, + highlightedIndex, + getItemProps, + openMenu, + } = useSelect({ + items: options, + // @ts-expect-error – there are two params but we don't need the second one + isItemDisabled: (item) => item.disabled, + onSelectedItemChange: ({ selectedItem }) => { + if (selectedItem) { + handleSelectedItemChange(selectedItem); + } + }, + onIsOpenChange: ({ isOpen }) => { + setDropdownOpen(isOpen ?? false); + }, + itemToString: (item) => (item ? item.label : ''), + }); const handleManage = () => { //TODO: implement manage handler @@ -103,13 +107,17 @@ export const UserSelect = ({ options, value }: UserSelectProps) => {