Skip to content

Commit

Permalink
FIX bug on option creation with select input
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinovega committed Nov 16, 2023
1 parent e21d4d9 commit 813167b
Show file tree
Hide file tree
Showing 2 changed files with 5,569 additions and 5,565 deletions.
5 changes: 2 additions & 3 deletions src/inputs/SelectInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export const SelectInput = <T extends { [x: string]: any },>(props: {
}, [props.value, values, props.defaultValue, loading])

useEffect(() => {
console.debug('get possoible values')
if (props.optionsFrom) {
const cond = option(props.fetchCondition)
.map(cond => cond())
Expand Down Expand Up @@ -154,10 +153,10 @@ export const SelectInput = <T extends { [x: string]: any },>(props: {
.flatMap(createdOpt => transform(createdOpt))
.getOrElse(valueToSelectOption(label, values) as SelectOption)

setValues([...values, createdValue])
setValues([...values || [], createdValue])

if (props.isMulti) {
onChange([...(value as SelectOption[]), createdValue])
onChange([...(value as SelectOption[]) || [], createdValue])
} else {
onChange(createdValue)
}
Expand Down
Loading

0 comments on commit 813167b

Please sign in to comment.