File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -197,7 +197,7 @@ export function filterOptions(
197
197
let filterFunc : FilterFunc < SelectOptionsType [ number ] > ;
198
198
199
199
if ( filterOption === false ) {
200
- return options ;
200
+ return [ ... options ] ;
201
201
}
202
202
if ( typeof filterOption === 'function' ) {
203
203
filterFunc = filterOption ;
Original file line number Diff line number Diff line change @@ -386,4 +386,17 @@ describe('Select.Tags', () => {
386
386
expect ( findSelection ( wrapper ) . text ( ) ) . toEqual ( 'f' ) ;
387
387
} ) ;
388
388
} ) ;
389
+
390
+ it ( 'not modify origin options' , ( ) => {
391
+ const errSpy = jest . spyOn ( console , 'error' ) ;
392
+ const wrapper = mount ( < Select mode = "tags" filterOption = { false } options = { [ ] } /> ) ;
393
+ toggleOpen ( wrapper ) ;
394
+ wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : 'a' } } ) ;
395
+ wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : 'ab' } } ) ;
396
+ wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : 'a' } } ) ;
397
+ wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : '' } } ) ;
398
+
399
+ expect ( errSpy ) . not . toHaveBeenCalled ( ) ;
400
+ errSpy . mockRestore ( ) ;
401
+ } ) ;
389
402
} ) ;
You can’t perform that action at this time.
0 commit comments