File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -75,15 +75,21 @@ function MultiSelect({
7575
7676 for ( const value of defaultValArr ) {
7777 const matchedVals = optionString . match (
78- new RegExp ( `{+?.[^{]*?"${ value } "}` , 'g' )
78+ new RegExp (
79+ `{+?.[^{]*?"${ value
80+ . replace ( / [ - [ \] { } ( ) * + ? . , \\ ^ $ | # \s ] / g, '\\$&' ) // escape special chars
81+ . replace ( / " / g, '\\\\$&' ) } "}`, // escape " as \\
82+ 'g'
83+ )
7984 )
85+
8086 if ( matchedVals ) {
8187 if ( matchedVals . length === 1 ) {
8288 defaultValueObj . push ( JSON . parse ( matchedVals ) )
8389 } else if ( matchedVals . length > 1 ) {
8490 defaultValueObj . push ( JSON . parse ( `[${ matchedVals . join ( ',' ) } ]` ) )
8591 }
86- } else if ( value !== '' && value !== null ) {
92+ } else if ( value !== '' && value !== null && customValue ) {
8793 setExtraValue ( value )
8894 defaultValueObj . push ( { label : value , value } )
8995 }
@@ -259,7 +265,6 @@ function MultiSelect({
259265 tmp = tmp . filter ( ( itm ) => itm . value !== newValObj . value )
260266 }
261267 }
262-
263268 setNewValue ( tmp )
264269 setSearch ( null )
265270 document . querySelector ( '.msl-input' ) . innerHTML = ''
You can’t perform that action at this time.
0 commit comments