Skip to content

Commit 3b4e416

Browse files
committed
fix: show platform-aware keyboard shortcut hint in DocsSearch
Mac shows ⌘K, Windows/Linux shows Ctrl+K
1 parent 48d43f0 commit 3b4e416

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

frontend/src/components/docs/DocsSearch.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState, useCallback } from 'react'
1+
import { useEffect, useState, useCallback, useMemo } from 'react'
22
import { useNavigate } from 'react-router-dom'
33
import {
44
CommandDialog,
@@ -174,6 +174,11 @@ const groupedPages = docsPages.reduce((acc, page) => {
174174
export function DocsSearch() {
175175
const [open, setOpen] = useState(false)
176176
const navigate = useNavigate()
177+
178+
const isMac = useMemo(() => {
179+
if (typeof navigator === 'undefined') return true
180+
return navigator.platform.toLowerCase().includes('mac')
181+
}, [])
177182

178183
useEffect(() => {
179184
const down = (e: KeyboardEvent) => {
@@ -201,7 +206,7 @@ export function DocsSearch() {
201206
<SearchIcon className="w-4 h-4" />
202207
<span className="flex-1 text-left">Search docs...</span>
203208
<kbd className="hidden sm:inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] font-medium text-gray-500 bg-white/5 border border-white/10 rounded">
204-
<span className="text-xs"></span>K
209+
<span className="text-xs">{isMac ? '⌘' : 'Ctrl+'}</span>K
205210
</kbd>
206211
</button>
207212

0 commit comments

Comments
 (0)