@@ -233,6 +233,7 @@ class Select extends React.Component<Partial<ISelectProps>, ISelectState> {
233
233
public dropdownContainer : Element | null = null ;
234
234
public blurTimer : number | null = null ;
235
235
public focusTimer : number | null = null ;
236
+ public comboboxTimer : number | null = null ;
236
237
237
238
// tslint:disable-next-line:variable-name
238
239
private _focused : boolean = false ;
@@ -304,6 +305,7 @@ class Select extends React.Component<Partial<ISelectProps>, ISelectState> {
304
305
public componentWillUnmount ( ) {
305
306
this . clearFocusTime ( ) ;
306
307
this . clearBlurTime ( ) ;
308
+ this . clearComboboxTime ( ) ;
307
309
if ( this . dropdownContainer ) {
308
310
ReactDOM . unmountComponentAtNode ( this . dropdownContainer ) ;
309
311
document . body . removeChild ( this . dropdownContainer ) ;
@@ -371,7 +373,7 @@ class Select extends React.Component<Partial<ISelectProps>, ISelectState> {
371
373
} ;
372
374
373
375
public onInputKeyDown = ( event : React . ChangeEvent < HTMLInputElement > | KeyboardEvent ) => {
374
- const { disabled, combobox } = this . props ;
376
+ const { disabled, combobox, defaultActiveFirstOption } = this . props ;
375
377
if ( disabled ) {
376
378
return ;
377
379
}
@@ -406,6 +408,13 @@ class Select extends React.Component<Partial<ISelectProps>, ISelectState> {
406
408
if ( isRealOpen || ! combobox ) {
407
409
event . preventDefault ( ) ;
408
410
}
411
+
412
+ // Hard close popup to avoid lock of non option in combobox mode
413
+ if ( isRealOpen && combobox && defaultActiveFirstOption === false ) {
414
+ this . comboboxTimer = setTimeout ( ( ) => {
415
+ this . setOpenState ( false ) ;
416
+ } ) ;
417
+ }
409
418
} else if ( keyCode === KeyCode . ESC ) {
410
419
if ( state . open ) {
411
420
this . setOpenState ( false ) ;
@@ -800,6 +809,7 @@ class Select extends React.Component<Partial<ISelectProps>, ISelectState> {
800
809
backfillValue : '' ,
801
810
} ;
802
811
// clear search input value when open is false in singleMode.
812
+ // https://github.com/ant-design/ant-design/issues/16572
803
813
if ( ! open && isSingleMode ( props ) && props . showSearch ) {
804
814
this . setInputValue ( '' , fireSearch ) ;
805
815
}
@@ -961,6 +971,13 @@ class Select extends React.Component<Partial<ISelectProps>, ISelectState> {
961
971
}
962
972
} ;
963
973
974
+ public clearComboboxTime = ( ) => {
975
+ if ( this . comboboxTimer ) {
976
+ clearTimeout ( this . comboboxTimer ) ;
977
+ this . comboboxTimer = null ;
978
+ }
979
+ } ;
980
+
964
981
public updateFocusClassName = ( ) => {
965
982
const rootRef = this . rootRef ;
966
983
const props = this . props ;
0 commit comments