Skip to content

Commit a85e5b0

Browse files
committed
feat: add shortcut for open search
1 parent f44e622 commit a85e5b0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/app/layout.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ClerkProvider } from '@clerk/nextjs'
1010
import PKG from '~/../package.json'
1111
import { HydrationEndDetector } from '~/components/common/HydrationEndDetector'
1212
import { Root } from '~/components/layout/root/Root'
13+
import { SearchPanelWithHotKey } from '~/components/widgets/shared/SearchFAB'
1314
import { TocAutoScroll } from '~/components/widgets/toc/TocAutoScroll'
1415
import { attachUA } from '~/lib/attach-ua'
1516
import { sansFont, serifFont } from '~/lib/fonts'
@@ -136,6 +137,7 @@ export default async function RootLayout(props: Props) {
136137
<Root>{children}</Root>
137138

138139
<TocAutoScroll />
140+
<SearchPanelWithHotKey />
139141
<Analyze />
140142
</Providers>
141143
<ToastContainer />

src/components/widgets/shared/SearchFAB.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ export const SearchFAB = () => {
4040
>
4141
<i className="icon-[mingcute--search-line]" />
4242
</FABPortable>
43-
<WithHotKey />
44-
<SearchPanel />
4543
</>
4644
)
4745
}
4846

49-
const WithHotKey = () => {
47+
export const SearchPanelWithHotKey = () => {
5048
useEffect(() => {
5149
const handler = (e: KeyboardEvent) => {
5250
if (e.key === 'k' && e.metaKey) {
@@ -68,7 +66,7 @@ const WithHotKey = () => {
6866
document.removeEventListener('keydown', handler)
6967
}
7068
}, [])
71-
return null
69+
return <SearchPanel />
7270
}
7371

7472
const SearchPanel = () => {

0 commit comments

Comments
 (0)