File tree Expand file tree Collapse file tree
src/components/fields/ComboBox Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -331,23 +331,13 @@ export const ComboBox = forwardRef(function ComboBox<T extends object>(
331331 let onKeyPress = useEvent ( ( e : KeyboardEvent ) => {
332332 if ( e . key === 'Enter' ) {
333333 if ( ! props . allowsCustomValue && state . isOpen ) {
334- const inputValue = inputRef ?. current ?. value ;
334+ const option = [ ... state . collection ] [ 0 ] ?. key ;
335335
336- if ( inputValue === '' ) {
337- state . close ( ) ;
338- props . onSelectionChange ?.( null ) ;
336+ if ( option && selectedKey !== option ) {
337+ props . onSelectionChange ?.( option ) ;
339338
340339 e . stopPropagation ( ) ;
341340 e . preventDefault ( ) ;
342- } else {
343- const option = [ ...state . collection ] [ 0 ] ?. key ;
344-
345- if ( option && selectedKey !== option ) {
346- props . onSelectionChange ?.( option ) ;
347-
348- e . stopPropagation ( ) ;
349- e . preventDefault ( ) ;
350- }
351341 }
352342 // If a custom value is allowed, we need to check if the input value is in the collection.
353343 } else if ( props . allowsCustomValue ) {
You can’t perform that action at this time.
0 commit comments