File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -669,7 +669,7 @@ class Select extends React.Component {
669
669
} ;
670
670
// clear search input value when open is false in singleMode.
671
671
if ( ! open && isSingleMode ( props ) && props . showSearch ) {
672
- this . setInputValue ( '' ) ;
672
+ this . setInputValue ( '' , false ) ;
673
673
}
674
674
if ( ! open ) {
675
675
this . maybeFocus ( open , needFocus ) ;
Original file line number Diff line number Diff line change @@ -350,6 +350,24 @@ describe('Select', () => {
350
350
expect ( handleSearch ) . not . toBeCalled ( ) ;
351
351
} ) ;
352
352
353
+ // https://github.com/ant-design/ant-design/issues/10817
354
+ it ( 'not fires extra search event when user search and select' , ( ) => {
355
+ const handleSearch = jest . fn ( ) ;
356
+ const wrapper = mount (
357
+ < Select
358
+ showSearch
359
+ onSearch = { handleSearch }
360
+ >
361
+ < Option value = "1" > 1</ Option >
362
+ < Option value = "2" > 2</ Option >
363
+ </ Select >
364
+ ) ;
365
+ wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : '1' } } ) ;
366
+ wrapper . find ( 'MenuItem' ) . first ( ) . simulate ( 'click' ) ;
367
+ expect ( handleSearch ) . toHaveBeenCalledTimes ( 1 ) ;
368
+ } ) ;
369
+
370
+
353
371
describe ( 'focus' , ( ) => {
354
372
let handleFocus ;
355
373
let wrapper ;
You can’t perform that action at this time.
0 commit comments