File tree 1 file changed +20
-5
lines changed
1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { CommandList , Command as CommandPrimitive } from "cmdk" ;
2
- import { Command , CommandGroup , CommandShortcut } from "@/shadcn/ui/command" ;
2
+ import {
3
+ Command ,
4
+ CommandGroup ,
5
+ CommandItem ,
6
+ CommandShortcut ,
7
+ } from "@/shadcn/ui/command" ;
3
8
import { cn } from "@/lib/utils" ;
4
9
import {
5
10
queryAtom ,
@@ -139,10 +144,12 @@ export function SearchBar({
139
144
className = "ml-2 flex-1 bg-transparent outline-none placeholder:text-base-8"
140
145
/>
141
146
< div className = "ml-auto flex flex-row opacity-0 group-focus-within:opacity-100 " >
142
- < CommandShortcut className = "pointer-events-none opacity-80" >
143
- < span className = "mr-1 rounded-sm bg-base-4 p-0.5" > ⇪</ span >
144
- < span className = "rounded-sm bg-base-4 p-0.5" > ↵</ span >
145
- </ CommandShortcut >
147
+ { query . length > 0 && (
148
+ < CommandShortcut className = "pointer-events-none opacity-80" >
149
+ { /* <span className="mr-1 rounded-sm bg-base-4 p-0.5">⇪</span> */ }
150
+ < span className = "rounded-sm bg-base-4 p-0.5" > ↵</ span >
151
+ </ CommandShortcut >
152
+ ) }
146
153
< button
147
154
type = "submit"
148
155
className = "-my-2 -mr-1 flex size-8 items-center rounded-md text-base-11 transition-all hover:bg-base-5 hover:text-primary-11"
@@ -193,6 +200,14 @@ export function SearchBar({
193
200
</ div >
194
201
}
195
202
>
203
+ { query . length > 0 && (
204
+ // Add a dummy item to make the <enter> key search by default.
205
+ < CommandItem
206
+ onSelect = { doSearch }
207
+ className = "hidden"
208
+ value = "-"
209
+ />
210
+ ) }
196
211
{ autocomplete . map ( ( item ) => {
197
212
return (
198
213
< AutocompleteDropdownItem
You can’t perform that action at this time.
0 commit comments