@@ -174,6 +174,12 @@ export const FormFieldSelectReactComp: FC<FormFieldSelectProps> = (props) => {
174174
175175 const className = useClassName ( props )
176176 const classNameSelectReact = useClassName ( props , { el : 'select-react' } )
177+ let value
178+ if ( Array . isArray ( initial ) ) {
179+ value = findDefaultArray ( options , initial )
180+ } else {
181+ value = findDefault ( options , initial )
182+ }
177183
178184 const reactSelectOnChanged = ( ) => {
179185 // TODO this is a hack to wait for the input to be updated, can we do better?
@@ -191,7 +197,7 @@ export const FormFieldSelectReactComp: FC<FormFieldSelectProps> = (props) => {
191197 className = { classNameSelectReact }
192198 isMulti = { multiple ?? false }
193199 isClearable
194- defaultValue = { findDefault ( options , initial ) }
200+ defaultValue = { value }
195201 name = { name }
196202 required = { required }
197203 isDisabled = { locked }
@@ -220,6 +226,11 @@ const SelectOptionComp: FC<{ option: SelectOption | SelectGroup }> = ({ option }
220226 }
221227}
222228
229+ function findDefaultArray ( options : SelectOptions , value : string [ ] ) : SelectOption [ ] {
230+ const foundValues = value . map ( ( v ) => findDefault ( options , v ) )
231+ return foundValues . filter ( ( v ) => v ) as SelectOption [ ]
232+ }
233+
223234function findDefault ( options : SelectOptions , value ?: string ) : SelectOption | undefined {
224235 for ( const option of options ) {
225236 if ( 'options' in option ) {
0 commit comments