@@ -110,29 +110,28 @@ function SingleSelect({
110110 const handleSelect = ( option : ISelectOption ) => {
111111 if ( option . disabled ) return
112112
113- const originalOption = optionsList . find ( ( opt ) => opt . value === option . value )
113+ const originalOption = optionsList ?. find (
114+ ( opt ) => String ( opt ?. value ) === String ( option ?. value )
115+ )
114116
115117 setSelectedOption ( originalOption || option )
116118 setIsOpen ( false )
117119
118120 onChangeSelect ?.( originalOption || option )
119121 }
120122
121- const optionsWithSelected = optionsList . map ( ( opt ) => ( {
123+ const optionsWithSelected = optionsList ? .map ( ( opt ) => ( {
122124 ...opt ,
123- selected : opt . value === value
125+ selected :
126+ String ( opt ?. value ) === String ( value ) ||
127+ String ( opt ?. label ) . toLowerCase ( ) === String ( value ) . toLowerCase ( )
124128 } ) )
125129
126130 const getInputLabel = ( ) => {
127- let inputLabel = label
128- if ( ! isFilter && ! selectedOption ) return ''
129- if ( ! selectedOption ) return inputLabel
131+ if ( ! isFilter && ! selectedOption ) return placeholder || label || ''
132+ if ( ! selectedOption ) return placeholder || label || ''
130133
131- return selectedOption . value === ''
132- ? inputLabel
133- : ( inputLabel =
134- optionsList . find ( ( opt ) => opt . value === selectedOption . value )
135- ?. label || label )
134+ return selectedOption . label || selectedOption . value . toString ( )
136135 }
137136
138137 useEffect ( ( ) => {
@@ -149,8 +148,19 @@ function SingleSelect({
149148 } , [ ] )
150149
151150 useEffect ( ( ) => {
152- const found = optionsList . find ( ( opt ) => opt . value === value )
153- setSelectedOption ( found || null )
151+ const found = optionsList ?. find (
152+ ( opt ) => String ( opt ?. value ) === String ( value )
153+ )
154+
155+ const foundByLabel =
156+ ! found && value
157+ ? optionsList ?. find (
158+ ( opt ) =>
159+ String ( opt ?. label ) . toLowerCase ( ) === String ( value ) . toLowerCase ( )
160+ )
161+ : null
162+
163+ setSelectedOption ( found || foundByLabel || null )
154164 } , [ value , optionsList ] )
155165
156166 return (
@@ -224,9 +234,8 @@ function SingleSelect({
224234 </ Text >
225235 </ div >
226236 ) }
227- { optionsWithSelected . map ( ( option ) => {
237+ { optionsWithSelected ? .map ( ( option ) => {
228238 const { value, label, disabled } = option
229-
230239 return (
231240 < Flex
232241 className = { composeClasses (
0 commit comments