Skip to content

Commit

Permalink
Merge pull request #22 from Yukthiw/yukthi/searchbar-comma-seperated-…
Browse files Browse the repository at this point in the history
…values

Feat: Entering (or pasting) comma seperated list in search bar seperates them into individual genes
  • Loading branch information
Yukthiw authored Oct 9, 2023
2 parents fc267e0 + 35b91f0 commit b57b571
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Eplant/UI/LeftNav/GeneSearch/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ export default function SearchBar(props: {
const updateOptions = React.useRef<(text: string) => void>()
const theme = useTheme()

function handleChange(input: string[]){
if(input.length > 0){
// If input is a comma seperated list, will split into seperate genes
setValue([...input.slice(0, -1), ...input.slice(-1)[0].split(",")])
}else{
setValue(input)
}
}

React.useEffect(() => {
updateOptions.current = debounce(async (newValue) => {
const newoptions = await props.complete?.(newValue)
Expand All @@ -46,7 +55,7 @@ export default function SearchBar(props: {

return (
<Autocomplete
onChange={(event, newVal) => setValue(newVal)}
onChange={(event, newVal) => handleChange(newVal)}
value={value}
id={id}
options={options}
Expand Down

0 comments on commit b57b571

Please sign in to comment.