@@ -97,6 +97,14 @@ export const SelectPickerTextArea = ({
9797
9898 useThrottledEffect ( reInitHeight , 500 , [ inputValue ] )
9999
100+ const handleCreateOption = ( newValue : string ) => {
101+ onChange ?.(
102+ { label : newValue , value : newValue } ,
103+ { action : 'create-option' , option : { label : newValue , value : newValue } } ,
104+ )
105+ selectRef . current . blurInput ( )
106+ }
107+
100108 const onInputChange = ( newValue : string , { action } : InputActionMeta ) => {
101109 if ( action === ReactSelectInputAction . inputChange ) {
102110 setInputValue ( newValue )
@@ -108,20 +116,16 @@ export const SelectPickerTextArea = ({
108116 } )
109117 }
110118 } else if ( action === ReactSelectInputAction . inputBlur ) {
119+ if ( isCreatable ) {
120+ handleCreateOption ( inputValue )
121+ return
122+ }
111123 // Reverting input to previously selected value in case of blur event. (no-selection)
112124 const selectValue = value as SingleValue < SelectPickerOptionType < string > >
113125 setInputValue ( selectValue ?. value || '' )
114126 }
115127 }
116128
117- const handleCreateOption = ( newValue : string ) => {
118- onChange ?.(
119- { label : newValue , value : newValue } ,
120- { action : 'create-option' , option : { label : newValue , value : newValue } } ,
121- )
122- selectRef . current . blurInput ( )
123- }
124-
125129 const handleKeyDown = ( event : React . KeyboardEvent < HTMLDivElement > ) => {
126130 if ( event . key === 'Enter' && event . shiftKey ) {
127131 // Prevent the default Enter key behavior
0 commit comments