Skip to content
Open
Show file tree
Hide file tree
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 @@ -33,6 +33,7 @@ export interface MultiSelectBoxProps extends React.HTMLAttributes<HTMLDivElement
defaultValue?: string[];
value?: string[];
onValueChange?: (value: string[]) => void;
onInputValueChange?: (value: string) => void;
placeholder?: string;
disabled?: boolean;
icon?: React.ElementType | React.JSXElementConstructor<any>;
Expand All @@ -44,6 +45,7 @@ const MultiSelectBox = React.forwardRef<HTMLDivElement, MultiSelectBoxProps>((pr
defaultValue,
value,
onValueChange,
onInputValueChange,
placeholder = "Select...",
disabled = false,
icon,
Expand Down Expand Up @@ -87,6 +89,11 @@ const MultiSelectBox = React.forwardRef<HTMLDivElement, MultiSelectBoxProps>((pr
onValueChange?.(newSelectedItems);
};

const handleInputValueChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setSearchQuery(e.target.value);
onInputValueChange?.(e.target.value);
};

const handleReset = () => {
setSelectedValue([]);
onValueChange?.([]);
Expand Down Expand Up @@ -224,7 +231,7 @@ const MultiSelectBox = React.forwardRef<HTMLDivElement, MultiSelectBoxProps>((pr
fontSize.sm,
fontWeight.md,
)}
onChange={(e) => setSearchQuery(e.target.value)}
onChange={handleInputValueChange}
/>
</div>
<SelectedValueContext.Provider
Expand Down
5 changes: 5 additions & 0 deletions src/components/input-elements/SelectBox/SelectBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface SelectBoxProps extends React.HTMLAttributes<HTMLDivElement> {
defaultValue?: string;
value?: string;
onValueChange?: (value: string) => void;
onInputValueChange?: (value: string) => void;
placeholder?: string;
disabled?: boolean;
icon?: React.ElementType | React.JSXElementConstructor<any>;
Expand All @@ -48,6 +49,7 @@ const SelectBox = React.forwardRef<HTMLDivElement, SelectBoxProps>((props, ref)
defaultValue,
value,
onValueChange,
onInputValueChange,
placeholder = "Select...",
disabled = false,
icon,
Expand All @@ -56,6 +58,7 @@ const SelectBox = React.forwardRef<HTMLDivElement, SelectBoxProps>((props, ref)
onKeyDown,
...other
} = props;

const valueToNameMapping = useMemo(() => constructValueToNameMapping(children), [children]);

const [selectedValue, setSelectedValue] = useInternalState(defaultValue, value);
Expand Down Expand Up @@ -107,6 +110,8 @@ const SelectBox = React.forwardRef<HTMLDivElement, SelectBoxProps>((props, ref)
const handleInputValueChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setSearchQuery(e.target.value);
setInputValue(e.target.value);

onInputValueChange?.(e.target.value);
};

const [hoveredValue, handleKeyDown] = useSelectOnKeyDown(
Expand Down