Commit 4b80d22 1 parent c56935a commit 4b80d22 Copy full SHA for 4b80d22
File tree 2 files changed +22
-4
lines changed
2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 1
1
"use client" ;
2
2
3
+ import React from "react" ;
3
4
import Link from "next/link" ;
4
5
import type { PageTree } from "fumadocs-core/server" ;
5
6
import { AlignLeftIcon , PanelLeftCloseIcon , SearchIcon } from "lucide-react" ;
@@ -21,6 +22,7 @@ export const MobileNav = ({
21
22
className ?: string ;
22
23
items : PageTree . Node [ ] ;
23
24
} ) => {
25
+ const [ isOpen , setOpen ] = React . useState ( false ) ;
24
26
return (
25
27
< header
26
28
className = { cn (
@@ -29,7 +31,7 @@ export const MobileNav = ({
29
31
) }
30
32
>
31
33
< div className = "max-w-(--breakpoint-2xl) container flex h-14 w-full items-center justify-between" >
32
- < DialogRoot >
34
+ < DialogRoot isOpen = { isOpen } onOpenChange = { setOpen } >
33
35
< Button variant = "quiet" size = "sm" shape = "square" >
34
36
< AlignLeftIcon />
35
37
</ Button >
@@ -65,7 +67,11 @@ export const MobileNav = ({
65
67
</ Button >
66
68
</ div >
67
69
< div className = "p-2" >
68
- < SearchCommand >
70
+ < SearchCommand
71
+ onAction = { ( ) => {
72
+ setOpen ( false ) ;
73
+ } }
74
+ >
69
75
< Button
70
76
prefix = { < SearchIcon /> }
71
77
variant = "outline"
Original file line number Diff line number Diff line change @@ -23,11 +23,13 @@ import { searchConfig } from "@/config";
23
23
interface SearchCommandProps {
24
24
keyboardShortcut ?: boolean ;
25
25
children : React . ReactNode ;
26
+ onAction ?: ( ) => void ;
26
27
}
27
28
28
29
export function SearchCommand ( {
29
30
keyboardShortcut,
30
31
children,
32
+ onAction,
31
33
} : SearchCommandProps ) {
32
34
const { search, setSearch, query } = useDocsSearch ( { type : "fetch" } ) ;
33
35
const results =
@@ -48,7 +50,11 @@ export function SearchCommand({
48
50
49
51
return (
50
52
< SearchCommandDialog keyboardShortcut = { keyboardShortcut } trigger = { children } >
51
- < Command inputValue = { search } onInputChange = { setSearch } className = "h-72" >
53
+ < Command
54
+ inputValue = { search }
55
+ onInputChange = { setSearch }
56
+ className = "h-72"
57
+ >
52
58
< div className = "p-1" >
53
59
< SearchFieldRoot placeholder = "Search" autoFocus className = "w-full" >
54
60
< InputRoot className = "focus-within:ring-1" >
@@ -57,7 +63,13 @@ export function SearchCommand({
57
63
</ InputRoot >
58
64
</ SearchFieldRoot >
59
65
</ div >
60
- < MenuContent className = "h-full overflow-y-scroll py-1" >
66
+ < MenuContent
67
+ onAction = { ( ) => {
68
+ setSearch ( "" ) ;
69
+ onAction ?.( ) ;
70
+ } }
71
+ className = "h-full overflow-y-scroll py-1"
72
+ >
61
73
{ results . map ( ( group ) => (
62
74
< MenuSection key = { group . id } title = { group . name } >
63
75
{ group . results . map ( ( item ) => (
You can’t perform that action at this time.
0 commit comments