Skip to content

Commit

Permalink
add a search in the model component
Browse files Browse the repository at this point in the history
  • Loading branch information
aakrem committed Apr 16, 2024
1 parent f59c702 commit ad08177
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,19 @@ interface GroupedSelectProps {
handleChange: (value: string) => void
}

const filterOption = (input: string, option?: {label: string; value: string}) =>
(option?.label ?? "").toLowerCase().includes(input.toLowerCase())

const GroupedSelect: React.FC<GroupedSelectProps> = ({choices, defaultValue, handleChange}) => {
const classes = useStyles()

return (
<Select
showSearch
defaultValue={defaultValue}
className={classes.select}
onChange={handleChange}
filterOption={filterOption}
options={Object.entries(choices).map(([groupLabel, groupChoices]) => ({
label: groupLabel,
options: groupChoices.map((choice) => ({
Expand Down

0 comments on commit ad08177

Please sign in to comment.