@@ -59,8 +59,8 @@ const SELECT_OPTIONS = [
5959 "isMultiple" ,
6060 "isDisabled" ,
6161 "loading" ,
62- "isGroupOption"
63- ] ;
62+ "isGroupOption" ,
63+ "closeOnSelect" ] ;
6464
6565const printAlertContent = ( element , value ) => {
6666 const printText = ( text , value ) =>
@@ -79,6 +79,8 @@ const printAlertContent = (element, value) => {
7979 return printText ( "A loader appears on the field" , value ) ;
8080 case "isGroupOption" :
8181 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 ) ;
8284 default :
8385 return null ;
8486 }
@@ -91,6 +93,7 @@ const Home = () => {
9193 const [ value , setValue ] = useState ( null ) ;
9294 const [ isClearable , setIsClearable ] = useState ( false ) ;
9395 const [ isMultiple , setIsMultiple ] = useState ( false ) ;
96+ const [ closeOnSelect , setCloseOnSelect ] = useState ( false ) ;
9497 const [ isSearchable , setIsSearchable ] = useState ( false ) ;
9598 const [ isDisabled , setIsDisabled ] = useState ( false ) ;
9699 const [ isGroupOption , setIsGroupOption ] = useState ( false ) ;
@@ -139,6 +142,10 @@ const Home = () => {
139142 }
140143 if ( action === "get" ) return isMultiple ;
141144 break ;
145+ case "closeOnSelect" :
146+ if ( action === "set" ) setCloseOnSelect ( valueData ) ;
147+ if ( action === "get" ) return closeOnSelect ;
148+ break ;
142149 case "isDisabled" :
143150 if ( action === "set" ) setIsDisabled ( valueData ) ;
144151 if ( action === "get" ) return isDisabled ;
@@ -158,7 +165,16 @@ const Home = () => {
158165 break ;
159166 }
160167 } ,
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+ ]
162178 ) ;
163179
164180 const handleCheck = useCallback (
@@ -239,6 +255,7 @@ const Home = () => {
239255 isClearable = { isClearable }
240256 isSearchable = { isSearchable }
241257 isMultiple = { isMultiple }
258+ closeOnSelect = { closeOnSelect }
242259 /*formatGroupLabel={(data) => (
243260 <div className={`py-2 text-xs flex items-center justify-between`}>
244261 <span className="font-bold">{data.label}</span>
@@ -282,6 +299,7 @@ const Home = () => {
282299 { printAlertContent ( "isDisabled" , isDisabled ) }
283300 { printAlertContent ( "loading" , loading ) }
284301 { printAlertContent ( "isGroupOption" , isGroupOption ) }
302+ { printAlertContent ( "closeOnSelect" , closeOnSelect ) }
285303 </ Alert >
286304 </ div >
287305 ) }
0 commit comments