File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,10 @@ import { ComponentProps } from 'react'
10
10
import type { SearchResult } from './SearchItem'
11
11
import SearchItem from './SearchItem'
12
12
13
- export const SearchModalContainer = ( { className } : ComponentProps < 'search' > ) => {
13
+ export const SearchModalContainer = ( {
14
+ className,
15
+ close,
16
+ } : ComponentProps < 'search' > & { close : ( ) => void } ) => {
14
17
const router = useRouter ( )
15
18
const { docs } = useDocs ( )
16
19
const [ query , setQuery ] = React . useState ( '' )
@@ -84,7 +87,10 @@ export const SearchModalContainer = ({ className }: ComponentProps<'search'>) =>
84
87
< Command . Item
85
88
key = { `search-item-${ index } ` }
86
89
value = { result . url }
87
- onSelect = { router . push }
90
+ onSelect = { ( value ) => {
91
+ router . push ( value )
92
+ close ( )
93
+ } }
88
94
className = "rounded-md transition-colors data-[selected=true]:bg-surface-container-high"
89
95
>
90
96
< SearchItem search = { query } result = { result } tabIndex = { - 1 } />
Original file line number Diff line number Diff line change @@ -36,7 +36,10 @@ function Search({ className }: ComponentProps<typeof Dialog.Trigger>) {
36
36
< Dialog . Close className = "size-full" />
37
37
</ Dialog . Overlay >
38
38
39
- < SearchModalContainer className = "relative mx-auto max-w-3xl rounded-md px-4 shadow-sm [--Search-Input-top:theme(spacing.8)] lg:[--Search-Input-top:theme(spacing.24)]" />
39
+ < SearchModalContainer
40
+ className = "relative mx-auto max-w-3xl rounded-md px-4 shadow-sm [--Search-Input-top:theme(spacing.8)] lg:[--Search-Input-top:theme(spacing.24)]"
41
+ close = { ( ) => setShowSearchModal ( false ) }
42
+ />
40
43
</ Dialog . Content >
41
44
</ Dialog . Portal >
42
45
</ Dialog . Root >
You can’t perform that action at this time.
0 commit comments