@@ -59,8 +59,8 @@ const SELECT_OPTIONS = [
59
59
"isMultiple" ,
60
60
"isDisabled" ,
61
61
"loading" ,
62
- "isGroupOption"
63
- ] ;
62
+ "isGroupOption" ,
63
+ "closeOnSelect" ] ;
64
64
65
65
const printAlertContent = ( element , value ) => {
66
66
const printText = ( text , value ) =>
@@ -79,6 +79,8 @@ const printAlertContent = (element, value) => {
79
79
return printText ( "A loader appears on the field" , value ) ;
80
80
case "isGroupOption" :
81
81
return printText ( "The options of the select field are grouped" , value ) ;
82
+ case "closeOnSelect" :
83
+ return printText ( "Close dropdown every time an option is selected" , value ) ;
82
84
default :
83
85
return null ;
84
86
}
@@ -91,6 +93,7 @@ const Home = () => {
91
93
const [ value , setValue ] = useState ( null ) ;
92
94
const [ isClearable , setIsClearable ] = useState ( false ) ;
93
95
const [ isMultiple , setIsMultiple ] = useState ( false ) ;
96
+ const [ closeOnSelect , setCloseOnSelect ] = useState ( false ) ;
94
97
const [ isSearchable , setIsSearchable ] = useState ( false ) ;
95
98
const [ isDisabled , setIsDisabled ] = useState ( false ) ;
96
99
const [ isGroupOption , setIsGroupOption ] = useState ( false ) ;
@@ -139,6 +142,10 @@ const Home = () => {
139
142
}
140
143
if ( action === "get" ) return isMultiple ;
141
144
break ;
145
+ case "closeOnSelect" :
146
+ if ( action === "set" ) setCloseOnSelect ( valueData ) ;
147
+ if ( action === "get" ) return closeOnSelect ;
148
+ break ;
142
149
case "isDisabled" :
143
150
if ( action === "set" ) setIsDisabled ( valueData ) ;
144
151
if ( action === "get" ) return isDisabled ;
@@ -158,7 +165,16 @@ const Home = () => {
158
165
break ;
159
166
}
160
167
} ,
161
- [ isClearable , isDisabled , isGroupOption , isMultiple , isSearchable , loading , value ]
168
+ [
169
+ isClearable ,
170
+ isDisabled ,
171
+ isGroupOption ,
172
+ isMultiple ,
173
+ closeOnSelect ,
174
+ isSearchable ,
175
+ loading ,
176
+ value
177
+ ]
162
178
) ;
163
179
164
180
const handleCheck = useCallback (
@@ -239,6 +255,7 @@ const Home = () => {
239
255
isClearable = { isClearable }
240
256
isSearchable = { isSearchable }
241
257
isMultiple = { isMultiple }
258
+ closeOnSelect = { closeOnSelect }
242
259
/*formatGroupLabel={(data) => (
243
260
<div className={`py-2 text-xs flex items-center justify-between`}>
244
261
<span className="font-bold">{data.label}</span>
@@ -282,6 +299,7 @@ const Home = () => {
282
299
{ printAlertContent ( "isDisabled" , isDisabled ) }
283
300
{ printAlertContent ( "loading" , loading ) }
284
301
{ printAlertContent ( "isGroupOption" , isGroupOption ) }
302
+ { printAlertContent ( "closeOnSelect" , closeOnSelect ) }
285
303
</ Alert >
286
304
</ div >
287
305
) }
0 commit comments