@@ -154,7 +154,7 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
154
154
onChange ?: ( value : ValueType , option : OptionType | OptionType [ ] ) => void ;
155
155
156
156
// >>> Blur
157
- tagsModeCommitOnBlur ?: boolean
157
+ preventCommitOnBlur ?: boolean
158
158
}
159
159
160
160
function isRawValue ( value : DraftValueType ) : value is RawValueType {
@@ -202,7 +202,7 @@ const Select = React.forwardRef(
202
202
onChange,
203
203
204
204
// Blur
205
- tagsModeCommitOnBlur = true ,
205
+ preventCommitOnBlur = false ,
206
206
207
207
...restProps
208
208
} = props ;
@@ -542,22 +542,24 @@ const Select = React.forwardRef(
542
542
setSearchValue ( searchText ) ;
543
543
setActiveValue ( null ) ;
544
544
545
+ if ( preventCommitOnBlur ) {
546
+ triggerChange ( '' ) ;
547
+ setSearchValue ( '' ) ;
548
+ return
549
+ }
550
+
545
551
// [Submit] Tag mode should flush input
546
552
if ( info . source === 'submit' ) {
547
- if ( ! tagsModeCommitOnBlur ) {
548
553
// prevent empty tags from appearing when you click the Enter button
549
- triggerChange ( '' ) ;
550
- setSearchValue ( '' ) ;
551
- } else {
552
- const formatted = ( searchText || '' ) . trim ( ) ;
553
- // prevent empty tags from appearing when you click the Enter button
554
- if ( formatted ) {
555
- const newRawValues = Array . from ( new Set < RawValueType > ( [ ...rawValues , formatted ] ) ) ;
556
- triggerChange ( newRawValues ) ;
557
- triggerSelect ( formatted , true ) ;
558
- setSearchValue ( '' ) ;
559
- }
554
+ const formatted = ( searchText || '' ) . trim ( ) ;
555
+ // prevent empty tags from appearing when you click the Enter button
556
+ if ( formatted ) {
557
+ const newRawValues = Array . from ( new Set < RawValueType > ( [ ...rawValues , formatted ] ) ) ;
558
+ triggerChange ( newRawValues ) ;
559
+ triggerSelect ( formatted , true ) ;
560
+ setSearchValue ( '' ) ;
560
561
}
562
+
561
563
return ;
562
564
}
563
565
0 commit comments