diff --git a/src/components/Select/Select.tsx b/src/components/Select/Select.tsx index 6c94181..8453293 100644 --- a/src/components/Select/Select.tsx +++ b/src/components/Select/Select.tsx @@ -110,7 +110,8 @@ export const BoemlySelect: React.FC = ({ ? prevSelectedOptions.filter((val) => val !== optionValue) : [...prevSelectedOptions, optionValue]; } else { - newSelectedOptions = [optionValue]; + const isOptionSelected = prevSelectedOptions.includes(optionValue); + newSelectedOptions = isOptionSelected ? [] : [optionValue]; // Deselect if selected, otherwise select setIsOpen(false); // Close dropdown for single select } @@ -139,17 +140,18 @@ export const BoemlySelect: React.FC = ({ // max height for the menu options, to show that there are more items to scroll const dynamicMaxHeight = useMemo(() => { - if (isMultiple && isSearchable) { - return '52'; + if ((isMultiple && isSearchable) || isSearchable) { + return '72'; } else if (isMultiple) { - return '48'; - } else if (isSearchable) { - return '52'; + return '80'; } - return '40'; + return '60'; }, [isMultiple, isSearchable]); + //40 48 52 56 60 64 68 72 80 84 88 90 100 + //80 + return ( = ({ filteredOptions.map(({ value, label, disabled = false }) => { const searchIndex = label.toLowerCase().indexOf(searchTerm.toLowerCase()); const isMatch = searchIndex !== -1; + const isSelected = selectedOptions.includes(value); let beforeMatch = label.slice(0, searchIndex); let match = label.slice(searchIndex, searchIndex + searchTerm.length); @@ -306,9 +309,14 @@ export const BoemlySelect: React.FC = ({ borderRadius="md" icon={null} iconSpacing="0" + bg={isSelected ? 'primary.100' : 'transparent'} > - + {isMatch ? ( <> {beforeMatch} @@ -330,9 +338,7 @@ export const BoemlySelect: React.FC = ({ tabIndex={-1} /> )} - {!isMultiple && selectedOptions.includes(value) && ( - - )} + {!isMultiple && isSelected && } );