File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed
Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import useComponentVisible from './useComponentVisible.jsx'
99
1010MultiSelect . defaultProps = {
1111 clearable : true ,
12+ clearAll : false ,
1213 downArrow : true ,
1314 singleSelect : false ,
1415 jsonValue : false ,
@@ -41,6 +42,7 @@ function MultiSelect({
4142 downArrowIcon,
4243 closeIcon,
4344 clearable,
45+ clearAll,
4446 downArrow,
4547 onChange,
4648 singleSelect,
@@ -75,8 +77,9 @@ function MultiSelect({
7577 onClickOutside : onMenuClose
7678 } )
7779
78- const calculatedWidth = `calc(100% - ${ clearable && downArrow ? 60 : downArrow || clearable ? 40 : 5
79- } px)`
80+ const calculatedWidth = `calc(100% - ${
81+ clearable && downArrow ? 60 : downArrow || clearable ? 40 : 5
82+ } px)`
8083
8184 const getValueObjFromOptios = ( defaultValue , options ) => {
8285 if ( ! defaultValue ) return [ ]
@@ -138,6 +141,12 @@ function MultiSelect({
138141 return [ ...searchedOptions , ...extraValues ]
139142 }
140143
144+ useEffect ( ( ) => {
145+ if ( clearAll && value . length > 0 ) {
146+ clearValue ( )
147+ }
148+ } , [ clearAll ] )
149+
141150 useEffect ( ( ) => {
142151 setOptions ( userOptions )
143152 } , [ userOptions ] )
@@ -501,12 +510,12 @@ function MultiSelect({
501510 } }
502511 />
503512 ) : (
504- ( ( search && ! search . length ) || ( options && ! options . length ) ) && (
505- < option className = 'msl-option msl-option-disable' >
506- { emptyDataLabel }
507- </ option >
508- )
509- ) }
513+ ( ( search && ! search . length ) || ( options && ! options . length ) ) && (
514+ < option className = 'msl-option msl-option-disable' >
515+ { emptyDataLabel }
516+ </ option >
517+ )
518+ ) }
510519 </ div >
511520 </ div >
512521 )
You can’t perform that action at this time.
0 commit comments