File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
apps/dashboard/src/components/primitives Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ export function Autocomplete<T extends AutocompleteItem>({
7070 // Form submission handler
7171 const handleSubmit = ( e : React . FormEvent ) => {
7272 e . preventDefault ( ) ;
73+ e . stopPropagation ( ) ;
7374
7475 if ( open && hasResults && highlightedIndex >= 0 ) {
7576 // Select highlighted item
@@ -141,9 +142,12 @@ export function Autocomplete<T extends AutocompleteItem>({
141142 setOpen ( false ) ;
142143 break ;
143144 case 'Enter' :
145+ e . preventDefault ( ) ;
144146 if ( highlightedIndex >= 0 ) {
145- e . preventDefault ( ) ;
146147 handleSelectItem ( items [ highlightedIndex ] ) ;
148+ } else if ( items . length > 0 ) {
149+ // If no item is highlighted but there are results, select the first item
150+ handleSelectItem ( items [ 0 ] ) ;
147151 }
148152 break ;
149153 }
You can’t perform that action at this time.
0 commit comments