Skip to content

Commit

Permalink
fix autocomplete clear, still needs submit
Browse files Browse the repository at this point in the history
  • Loading branch information
danactive committed Apr 7, 2024
1 parent 8db35ca commit 3c825fd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion next/src/components/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ export default function ComboBox(
<FormControl id="free-solo-with-text-demo">
<Autocomplete
value={valueText}
onChange={(event, newValue) => {
onChange={(event, newValue): void => {
if (typeof newValue === 'string') {
onChange({ label: newValue, value: newValue })
} else if (newValue?.label && newValue?.value) {
onChange({ label: newValue.label, value: newValue.value })
} else if (newValue === null) { // clear
onChange({ label: '', value: '' })
}
}}
filterOptions={(options, params) => {
Expand Down

0 comments on commit 3c825fd

Please sign in to comment.