@@ -152,6 +152,9 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
152152 value ?: ValueType | null ;
153153 defaultValue ?: ValueType | null ;
154154 onChange ?: ( value : ValueType , option : OptionType | OptionType [ ] ) => void ;
155+
156+ // >>> Blur
157+ tagsModeCommitOnBlur ?: boolean
155158}
156159
157160function isRawValue ( value : DraftValueType ) : value is RawValueType {
@@ -198,6 +201,9 @@ const Select = React.forwardRef(
198201 labelInValue,
199202 onChange,
200203
204+ // Blur
205+ tagsModeCommitOnBlur = true ,
206+
201207 ...restProps
202208 } = props ;
203209
@@ -538,15 +544,20 @@ const Select = React.forwardRef(
538544
539545 // [Submit] Tag mode should flush input
540546 if ( info . source === 'submit' ) {
541- const formatted = ( searchText || '' ) . trim ( ) ;
542- // prevent empty tags from appearing when you click the Enter button
543- if ( formatted ) {
544- const newRawValues = Array . from ( new Set < RawValueType > ( [ ...rawValues , formatted ] ) ) ;
545- triggerChange ( newRawValues ) ;
546- triggerSelect ( formatted , true ) ;
547- setSearchValue ( '' ) ;
547+ if ( ! tagsModeCommitOnBlur ) {
548+ // 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+ }
548560 }
549-
550561 return ;
551562 }
552563
0 commit comments