Skip to content

Commit

Permalink
Merge pull request #334 from universi-me/change#333/ajustes-no-react-…
Browse files Browse the repository at this point in the history
…select-modo-creatable-no-universiform
  • Loading branch information
julio-ufpb authored Dec 25, 2023
2 parents 5aa4957 + 59a1989 commit a4acc66
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/UniversiForm/UniversiForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,14 @@ export function UniversiForm(props : formProps){
object.onCreate(inputValue)
.then((options : any)=>{
setOptionsList(options)

// select created value in options preserving selected values
for(const option of options) {
if(option.label == inputValue) {
handleSelectChange(index, object.type === FormInputs.SELECT_MULTI ? [...values, option] : option)
break
}
}
})
}

Expand Down Expand Up @@ -454,6 +462,7 @@ export function UniversiForm(props : formProps){
<CreatableSelect isClearable placeholder={`Selecionar ${object.label}`} className="category-select" isMulti={object.type === FormInputs.SELECT_MULTI ? true : undefined} options={optionsList}
onChange={(value) => handleSelectChange(index, value)}
noOptionsMessage={()=>`Não foi possível encontrar ${object.label}`}
formatCreateLabel={(value) => `Criar "${value}"`}
classNamePrefix="category-item"
styles={object.stylesConfig}
required={object.required}
Expand Down

0 comments on commit a4acc66

Please sign in to comment.