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'
9
9
10
10
MultiSelect . defaultProps = {
11
11
clearable : true ,
12
+ clearAll : false ,
12
13
downArrow : true ,
13
14
singleSelect : false ,
14
15
jsonValue : false ,
@@ -41,6 +42,7 @@ function MultiSelect({
41
42
downArrowIcon,
42
43
closeIcon,
43
44
clearable,
45
+ clearAll,
44
46
downArrow,
45
47
onChange,
46
48
singleSelect,
@@ -75,8 +77,9 @@ function MultiSelect({
75
77
onClickOutside : onMenuClose
76
78
} )
77
79
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)`
80
83
81
84
const getValueObjFromOptios = ( defaultValue , options ) => {
82
85
if ( ! defaultValue ) return [ ]
@@ -138,6 +141,12 @@ function MultiSelect({
138
141
return [ ...searchedOptions , ...extraValues ]
139
142
}
140
143
144
+ useEffect ( ( ) => {
145
+ if ( clearAll && value . length > 0 ) {
146
+ clearValue ( )
147
+ }
148
+ } , [ clearAll ] )
149
+
141
150
useEffect ( ( ) => {
142
151
setOptions ( userOptions )
143
152
} , [ userOptions ] )
@@ -501,12 +510,12 @@ function MultiSelect({
501
510
} }
502
511
/>
503
512
) : (
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
+ ) }
510
519
</ div >
511
520
</ div >
512
521
)
You can’t perform that action at this time.
0 commit comments