File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
src/components/fields/ComboBox Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -366,11 +366,25 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
366366 }
367367 } ) ;
368368
369+ let onBlur = useEvent ( ( e : FocusEvent ) => {
370+ if (
371+ ! props . allowsCustomValue &&
372+ inputRef . current ?. value &&
373+ ! [ ...state . collection ]
374+ . map ( ( i ) => i . textValue )
375+ . includes ( inputRef . current ?. value )
376+ ) {
377+ props . onSelectionChange ?.( null ) ;
378+ }
379+ } ) ;
380+
369381 useEffect ( ( ) => {
370382 inputRef . current ?. addEventListener ( 'keydown' , onKeyPress , true ) ;
383+ inputRef . current ?. addEventListener ( 'blur' , onBlur , true ) ;
371384
372385 return ( ) => {
373386 inputRef . current ?. removeEventListener ( 'keydown' , onKeyPress , true ) ;
387+ inputRef . current ?. removeEventListener ( 'blur' , onBlur , true ) ;
374388 } ;
375389 } , [ ] ) ;
376390
You can’t perform that action at this time.
0 commit comments