Просмотр исходного кода

Make the settings menu one line per page, with search that stays on top (#659)

* Make the settings menu one line per page, with search that stays on top

* Honour the shortcut settings for the slash key, keep the menu mounted while searching, and show a page's description on keyboard focus
Bernt Christian Egeland 5 дней назад
Родитель
Сommit
c2373df4df

+ 2 - 1
messages/bg/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Търсене в настройките…",
     "label": "Търсене в настройките",
     "empty": "Няма настройка, съответстваща на „{query}“",
-    "shortcutHint": "Натиснете {shortcut} навсякъде, за да търсите"
+    "shortcutHint": "Натиснете {shortcut} навсякъде, за да търсите",
+    "resultsHint": "{count, plural, one {# резултат} other {# резултата}} · ↑↓ за придвижване · Esc за изчистване"
   }
 }

+ 2 - 1
messages/de/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Einstellungen suchen…",
     "label": "Einstellungen suchen",
     "empty": "Keine Einstellung passt zu „{query}“",
-    "shortcutHint": "Drücken Sie überall {shortcut}, um zu suchen"
+    "shortcutHint": "Drücken Sie überall {shortcut}, um zu suchen",
+    "resultsHint": "{count, plural, one {# Ergebnis} other {# Ergebnisse}} · ↑↓ zum Navigieren · Esc zum Leeren"
   }
 }

+ 2 - 1
messages/en/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Search settings…",
     "label": "Search settings",
     "empty": "No setting matches “{query}”",
-    "shortcutHint": "Press {shortcut} anywhere to search"
+    "shortcutHint": "Press {shortcut} anywhere to search",
+    "resultsHint": "{count, plural, one {# result} other {# results}} · ↑↓ to move · Esc to clear"
   }
 }

+ 2 - 1
messages/es/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Buscar ajustes…",
     "label": "Buscar ajustes",
     "empty": "Ningún ajuste coincide con \"{query}\"",
-    "shortcutHint": "Pulsa {shortcut} en cualquier lugar para buscar"
+    "shortcutHint": "Pulsa {shortcut} en cualquier lugar para buscar",
+    "resultsHint": "{count, plural, one {# resultado} other {# resultados}} · ↑↓ para navegar · Esc para borrar"
   }
 }

+ 2 - 1
messages/fr/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Rechercher un paramètre…",
     "label": "Rechercher un paramètre",
     "empty": "Aucun paramètre ne correspond à « {query} »",
-    "shortcutHint": "Appuyez sur {shortcut} n’importe où pour rechercher"
+    "shortcutHint": "Appuyez sur {shortcut} n’importe où pour rechercher",
+    "resultsHint": "{count, plural, one {# résultat} other {# résultats}} · ↑↓ pour naviguer · Échap pour effacer"
   }
 }

+ 2 - 1
messages/it/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Cerca impostazioni…",
     "label": "Cerca impostazioni",
     "empty": "Nessuna impostazione corrisponde a \"{query}\"",
-    "shortcutHint": "Premi {shortcut} ovunque per cercare"
+    "shortcutHint": "Premi {shortcut} ovunque per cercare",
+    "resultsHint": "{count, plural, one {# risultato} other {# risultati}} · ↑↓ per navigare · Esc per cancellare"
   }
 }

+ 2 - 1
messages/lt/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Ieškoti nustatymų…",
     "label": "Ieškoti nustatymų",
     "empty": "Joks nustatymas neatitinka „{query}“",
-    "shortcutHint": "Paspauskite {shortcut} bet kur, kad ieškotumėte"
+    "shortcutHint": "Paspauskite {shortcut} bet kur, kad ieškotumėte",
+    "resultsHint": "{count, plural, one {# rezultatas} few {# rezultatai} many {# rezultato} other {# rezultatų}} · ↑↓ naršyti · Esc išvalyti"
   }
 }

+ 2 - 1
messages/nb/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Søk i innstillinger…",
     "label": "Søk i innstillinger",
     "empty": "Ingen innstilling passer med «{query}»",
-    "shortcutHint": "Trykk {shortcut} hvor som helst for å søke"
+    "shortcutHint": "Trykk {shortcut} hvor som helst for å søke",
+    "resultsHint": "{count, plural, one {# treff} other {# treff}} · ↑↓ for å navigere · Esc for å tømme"
   }
 }

+ 2 - 1
messages/nl/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Instellingen zoeken…",
     "label": "Instellingen zoeken",
     "empty": "Geen instelling komt overeen met \"{query}\"",
-    "shortcutHint": "Druk overal op {shortcut} om te zoeken"
+    "shortcutHint": "Druk overal op {shortcut} om te zoeken",
+    "resultsHint": "{count, plural, one {# resultaat} other {# resultaten}} · ↑↓ om te navigeren · Esc om te wissen"
   }
 }

+ 2 - 1
messages/pl/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Szukaj ustawień…",
     "label": "Szukaj ustawień",
     "empty": "Żadne ustawienie nie pasuje do „{query}”",
-    "shortcutHint": "Naciśnij {shortcut} w dowolnym miejscu, aby wyszukać"
+    "shortcutHint": "Naciśnij {shortcut} w dowolnym miejscu, aby wyszukać",
+    "resultsHint": "{count, plural, one {# wynik} few {# wyniki} many {# wyników} other {# wyniku}} · ↑↓, aby nawigować · Esc, aby wyczyścić"
   }
 }

+ 2 - 1
messages/pt-BR/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Buscar configurações…",
     "label": "Buscar configurações",
     "empty": "Nenhuma configuração corresponde a \"{query}\"",
-    "shortcutHint": "Pressione {shortcut} em qualquer lugar para buscar"
+    "shortcutHint": "Pressione {shortcut} em qualquer lugar para buscar",
+    "resultsHint": "{count, plural, =0 {# resultados} one {# resultado} other {# resultados}} · ↑↓ para navegar · Esc para limpar"
   }
 }

+ 2 - 1
messages/pt-PT/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Pesquisar definições…",
     "label": "Pesquisar definições",
     "empty": "Nenhuma definição corresponde a \"{query}\"",
-    "shortcutHint": "Prima {shortcut} em qualquer lado para pesquisar"
+    "shortcutHint": "Prima {shortcut} em qualquer lado para pesquisar",
+    "resultsHint": "{count, plural, one {# resultado} other {# resultados}} · ↑↓ para navegar · Esc para limpar"
   }
 }

+ 2 - 1
messages/ru/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Поиск настроек…",
     "label": "Поиск настроек",
     "empty": "Нет настроек по запросу «{query}»",
-    "shortcutHint": "Нажмите {shortcut} в любом месте, чтобы начать поиск"
+    "shortcutHint": "Нажмите {shortcut} в любом месте, чтобы начать поиск",
+    "resultsHint": "{count, plural, one {# результат} few {# результата} many {# результатов} other {# результата}} · ↑↓ для перемещения · Esc для очистки"
   }
 }

+ 2 - 1
messages/tr/search.json

@@ -37,6 +37,7 @@
     "placeholder": "Ayarlarda ara…",
     "label": "Ayarlarda ara",
     "empty": "\"{query}\" ile eşleşen ayar yok",
-    "shortcutHint": "Aramak için herhangi bir yerde {shortcut} tuşuna basın"
+    "shortcutHint": "Aramak için herhangi bir yerde {shortcut} tuşuna basın",
+    "resultsHint": "{count, plural, one {# sonuç} other {# sonuç}} · Gezinmek için ↑↓ · Temizlemek için Esc"
   }
 }

+ 93 - 0
src/__tests__/app/settings/settings-nav-compact.test.tsx

@@ -0,0 +1,93 @@
+import { fireEvent, render, screen } from '@testing-library/react'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { SettingsNav } from '@/app/(authenticated)/settings/settings-nav'
+
+vi.mock('next/navigation', () => ({
+  usePathname: () => '/settings/company',
+  useRouter: () => ({ push: vi.fn() }),
+}))
+
+/**
+ * The settings menu beside the content: one line per page, a search box that
+ * a bare slash reaches, and results that take the menu's place.
+ */
+describe('the compact settings menu', () => {
+  afterEach(() => vi.unstubAllGlobals())
+
+  it('lists each page by its name alone and keeps the description as a tip', async () => {
+    // The tooltip measures its trigger, which jsdom has nothing for.
+    vi.stubGlobal(
+      'ResizeObserver',
+      class {
+        observe() {
+          // nothing to watch in a test
+        }
+        unobserve() {
+          // nothing to release in a test
+        }
+        disconnect() {
+          // nothing to release in a test
+        }
+      }
+    )
+    render(<SettingsNav isCloud supportEnabled />)
+
+    const company = screen.getByRole('link', { name: 'Company' })
+    expect(screen.queryByText('Business details & branding')).not.toBeInTheDocument()
+
+    // Reached with the keyboard, the row says what the page is for.
+    fireEvent.focus(company)
+    expect(await screen.findByRole('tooltip')).toHaveTextContent('Business details & branding')
+  })
+
+  it('shows what is found in place of the menu, and the menu again when cleared', () => {
+    render(<SettingsNav isCloud supportEnabled />)
+    const box = screen.getByRole('combobox', { name: 'Search settings' })
+    const menu = screen.getByRole('navigation')
+
+    fireEvent.change(box, { target: { value: 'company' } })
+    expect(screen.getAllByRole('option').length).toBeGreaterThan(0)
+    expect(screen.queryByRole('navigation')).not.toBeInTheDocument()
+    expect(screen.getByText(/results? · ↑↓ to move · Esc to clear/)).toBeInTheDocument()
+
+    fireEvent.keyDown(box, { key: 'Escape' })
+    // The same menu, not a new one: what watches it for a resize still does.
+    expect(screen.getByRole('navigation')).toBe(menu)
+    expect(screen.queryByRole('option')).not.toBeInTheDocument()
+  })
+
+  it('puts the cursor in the search box on a bare slash', () => {
+    render(<SettingsNav isCloud supportEnabled />)
+    const box = screen.getByRole('combobox', { name: 'Search settings' })
+
+    fireEvent.keyDown(document.body, { key: '/' })
+    expect(box).toHaveFocus()
+  })
+
+  it('leaves a slash typed into a field alone', () => {
+    render(
+      <>
+        <input aria-label="Workshop name" />
+        <SettingsNav isCloud supportEnabled />
+      </>
+    )
+    const field = screen.getByRole('textbox', { name: 'Workshop name' })
+    field.focus()
+
+    const typed = fireEvent.keyDown(field, { key: '/' })
+    expect(typed).toBe(true)
+    expect(field).toHaveFocus()
+  })
+
+  it('keeps the menu under the results on a narrow window, with no slash key', () => {
+    render(<SettingsNav isCloud supportEnabled mobile />)
+    const box = screen.getByRole('combobox', { name: 'Search settings' })
+
+    fireEvent.keyDown(document.body, { key: '/' })
+    expect(box).not.toHaveFocus()
+
+    fireEvent.change(box, { target: { value: 'company' } })
+    expect(screen.getAllByRole('option').length).toBeGreaterThan(0)
+    expect(screen.queryByText(/to move · Esc to clear/)).not.toBeInTheDocument()
+  })
+})

+ 24 - 0
src/__tests__/app/settings/settings-nav-no-shortcuts.test.tsx

@@ -0,0 +1,24 @@
+import { fireEvent, render, screen } from '@testing-library/react'
+import { describe, expect, it, vi } from 'vitest'
+import { SettingsNav } from '@/app/(authenticated)/settings/settings-nav'
+
+vi.mock('next/navigation', () => ({
+  usePathname: () => '/settings/company',
+  useRouter: () => ({ push: vi.fn() }),
+}))
+
+// Somebody who switched single-key shortcuts off under Keyboard shortcuts.
+vi.mock('@/features/shortcuts/Components/ShortcutsProvider', () => ({
+  useShortcuts: () => ({ prefs: { enabled: true, singleKeys: false } }),
+}))
+
+describe('the settings search with single-key shortcuts switched off', () => {
+  it('leaves the slash key alone and shows no hint of it', () => {
+    render(<SettingsNav isCloud supportEnabled />)
+    const box = screen.getByRole('combobox', { name: 'Search settings' })
+
+    fireEvent.keyDown(document.body, { key: '/' })
+    expect(box).not.toHaveFocus()
+    expect(screen.queryByText('/')).not.toBeInTheDocument()
+  })
+})

+ 22 - 4
src/__tests__/app/settings/settings-nav-support.test.tsx

@@ -1,5 +1,5 @@
-import { render, screen, within } from '@testing-library/react'
-import { describe, expect, it, vi } from 'vitest'
+import { fireEvent, render, screen, within } from '@testing-library/react'
+import { afterEach, describe, expect, it, vi } from 'vitest'
 import { SettingsNav } from '@/app/(authenticated)/settings/settings-nav'
 
 vi.mock('next/navigation', () => ({
@@ -16,6 +16,8 @@ function linksUnder(heading: string) {
 }
 
 describe('Support in the settings menu', () => {
+  afterEach(() => vi.unstubAllGlobals())
+
   it('sits under System, directly above About', () => {
     render(<SettingsNav isCloud supportEnabled />)
 
@@ -24,11 +26,27 @@ describe('Support in the settings menu', () => {
     expect(linksUnder('General')).not.toContain('/settings/support')
   })
 
-  it('says what the page is for in a line short enough to read whole', () => {
+  it('says what the page is for when the row is pointed at', async () => {
+    // The tooltip measures its trigger, which jsdom has nothing for.
+    vi.stubGlobal(
+      'ResizeObserver',
+      class {
+        observe() {
+          // nothing to watch in a test
+        }
+        unobserve() {
+          // nothing to release in a test
+        }
+        disconnect() {
+          // nothing to release in a test
+        }
+      }
+    )
     render(<SettingsNav isCloud supportEnabled />)
 
     const row = screen.getByRole('link', { name: /Support/ })
-    expect(row).toHaveTextContent('Get help & the support button')
+    fireEvent.focus(row)
+    expect(await screen.findByRole('tooltip')).toHaveTextContent('Get help & the support button')
   })
 
   it('stays out of the menu where support requests are switched off', () => {

+ 143 - 64
src/app/(authenticated)/settings/settings-nav.tsx

@@ -6,6 +6,7 @@ import { usePathname, useRouter } from 'next/navigation'
 import { useTranslations } from 'next-intl'
 import { Search, X } from 'lucide-react'
 import { cn } from '@/lib/utils'
+import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
 import type { PlanFeatures } from '@/lib/features'
 import {
   Select,
@@ -22,6 +23,8 @@ import {
 import { SETTINGS_PAGE_ICONS } from '@/features/settings/Lib/settingsPageIcons'
 import { requestSpotlight } from '@/features/settings/Components/SettingsSpotlight'
 import { useSettingsSearchItems } from '@/features/search/Lib/settingsItems'
+import { useShortcuts } from '@/features/shortcuts/Components/ShortcutsProvider'
+import { claimsPlainKeys } from '@/features/shortcuts/Lib/keys'
 import { prepareQuery, rank, splitByRanges } from '@/features/search/Lib/matcher'
 
 type NavProps = {
@@ -43,12 +46,23 @@ const RESULT_LIMIT = 12
  * fields included, to a short list that opens the page and lands on the
  * thing, so nobody has to guess which page "logo" or "due days" is under.
  * Arrow keys move, Enter opens, Escape clears.
+ *
+ * Beside the content it is given the menu as `children`: the box stays put
+ * while the menu scrolls, a bare slash puts the cursor in it, and what is
+ * found takes the menu's place. Above the content, on a narrow window, the
+ * results open under the box instead.
  */
 function SettingsSearch({
   features,
   isCloud,
   supportEnabled,
-}: Pick<NavProps, 'features' | 'isCloud' | 'supportEnabled'>) {
+  children,
+}: Pick<NavProps, 'features' | 'isCloud' | 'supportEnabled'> & { children?: React.ReactNode }) {
+  const inMenu = children !== undefined
+  // Somebody who switched shortcuts off, or the ones made of a single key,
+  // gets no slash key and no hint of one.
+  const { prefs } = useShortcuts()
+  const slashKey = inMenu && prefs.enabled && prefs.singleKeys
   const t = useTranslations('search.settingsSearch')
   const tSettings = useTranslations('settings')
   const router = useRouter()
@@ -91,12 +105,34 @@ function SettingsSearch({
     }
   }
 
+  // A bare slash from anywhere that is not being typed into. Only the box
+  // beside the content listens, and only while it can be seen.
+  useEffect(() => {
+    if (!slashKey) return
+    const onKey = (e: KeyboardEvent) => {
+      if (e.key !== '/' || e.ctrlKey || e.metaKey || e.altKey || claimsPlainKeys(e)) return
+      if (document.querySelector('[role="dialog"], [role="alertdialog"]')) return
+      const input = inputRef.current
+      if (!input || input.checkVisibility?.() === false) return
+      e.preventDefault()
+      input.focus()
+      input.select()
+    }
+    document.addEventListener('keydown', onKey)
+    return () => document.removeEventListener('keydown', onKey)
+  }, [slashKey])
+
   const searching = query.trim().length > 0
 
   return (
-    <div className="relative">
-      <div className="relative">
-        <Search className="pointer-events-none absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
+    <div className={cn('relative', inMenu && 'flex flex-col')}>
+      <div className={cn('relative', inMenu && 'sticky top-0 z-10 bg-background pb-2')}>
+        <Search
+          className={cn(
+            'pointer-events-none absolute left-3 h-4 w-4 text-muted-foreground',
+            inMenu ? 'top-2.5' : 'top-1/2 -translate-y-1/2'
+          )}
+        />
         <input
           ref={inputRef}
           type="search"
@@ -111,8 +147,21 @@ function SettingsSearch({
           onKeyDown={onKeyDown}
           placeholder={t('placeholder')}
           data-testid="settings-search"
-          className="h-9 w-full rounded-lg border bg-background pr-8 pl-9 text-sm shadow-xs outline-none transition-[border-color,box-shadow] placeholder:text-muted-foreground focus:border-primary/50 focus:ring-2 focus:ring-primary/15 [&::-webkit-search-cancel-button]:hidden"
+          className={cn(
+            'peer h-9 w-full rounded-lg border pr-8 pl-9 text-sm outline-none transition-[background-color,border-color,box-shadow] placeholder:text-muted-foreground focus:border-primary/50 focus:ring-2 focus:ring-primary/15 [&::-webkit-search-cancel-button]:hidden',
+            inMenu
+              ? 'border-transparent bg-muted focus:bg-background focus:ring-inset'
+              : 'bg-background shadow-xs'
+          )}
         />
+        {slashKey && !searching && (
+          <span
+            aria-hidden="true"
+            className="pointer-events-none absolute top-2 right-2 flex h-5 min-w-5 peer-focus:hidden items-center justify-center rounded border bg-background px-1 font-sans text-[11px] font-medium text-muted-foreground"
+          >
+            /
+          </span>
+        )}
         {searching && (
           <button
             type="button"
@@ -120,7 +169,10 @@ function SettingsSearch({
               setQuery('')
               inputRef.current?.focus()
             }}
-            className="absolute top-1/2 right-2 flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground"
+            className={cn(
+              'absolute right-2 flex h-5 w-5 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground',
+              inMenu ? 'top-2' : 'top-1/2 -translate-y-1/2'
+            )}
             aria-label={t('label')}
           >
             <X className="h-3.5 w-3.5" />
@@ -132,14 +184,16 @@ function SettingsSearch({
         <div
           id="settings-search-results"
           role="listbox"
-          className="mt-2 overflow-hidden rounded-lg border bg-popover shadow-md"
+          className={cn(!inMenu && 'mt-2 overflow-hidden rounded-lg border bg-popover shadow-md')}
         >
           {results.length === 0 ? (
-            <p className="px-3 py-4 text-center text-xs text-muted-foreground">
+            <p className="px-3 py-4 text-center text-xs text-muted-foreground" role="status">
               {t('empty', { query: query.trim() })}
             </p>
           ) : (
-            <ul className="max-h-[60vh] overflow-y-auto py-1">
+            <ul
+              className={cn(inMenu ? 'flex flex-col gap-0.5' : 'max-h-[60vh] overflow-y-auto py-1')}
+            >
               {results.map(({ item, match }, i) => {
                 const Icon = item.icon
                 return (
@@ -152,6 +206,7 @@ function SettingsSearch({
                       onClick={() => open(item.href, item.anchor)}
                       className={cn(
                         'flex w-full cursor-pointer items-center gap-3 px-3 py-2 text-left text-sm transition-colors',
+                        inMenu && 'rounded-lg',
                         i === active ? 'bg-primary/10 text-foreground' : 'hover:bg-muted'
                       )}
                     >
@@ -178,14 +233,29 @@ function SettingsSearch({
                           {item.locked ? ` · ${tSettings('nav.pro')}` : ''}
                         </span>
                       </span>
+                      {inMenu && i === active && (
+                        <span
+                          aria-hidden="true"
+                          className="flex h-5 min-w-5 shrink-0 items-center justify-center rounded border bg-background px-1 text-[11px] font-medium text-muted-foreground"
+                        >
+                          ↵
+                        </span>
+                      )}
                     </button>
                   </li>
                 )
               })}
             </ul>
           )}
+          {inMenu && results.length > 0 && (
+            <p className="px-3 pt-3 text-[11px] text-muted-foreground" role="status">
+              {t('resultsHint', { count: results.length })}
+            </p>
+          )}
         </div>
       )}
+      {/* Kept in the page while results show, so it is found again as it was. */}
+      {inMenu && <div hidden={searching}>{children}</div>}
     </div>
   )
 }
@@ -261,60 +331,69 @@ export function SettingsNav({
   }
 
   return (
-    <nav ref={navRef} className="flex flex-col gap-4">
-      <SettingsSearch features={features} isCloud={isCloud} supportEnabled={supportEnabled} />
-      {SETTINGS_CATEGORIES.map((category) => {
-        const visibleItems = pages.filter((p) => p.category === category)
-        if (visibleItems.length === 0) return null
-        return (
-          <div key={category}>
-            <p className="mb-1 px-3 text-xs font-semibold uppercase tracking-wider text-muted-foreground/60">
-              {t(`nav.categories.${category}`)}
-            </p>
-            <div className="flex flex-col gap-0.5">
-              {visibleItems.map((item) => {
-                const isActive = pathname === item.href
-                const isLocked = !!(item.gate && features && !features[item.gate])
-                const Icon = SETTINGS_PAGE_ICONS[item.key]
-                return (
-                  <Link
-                    key={item.href}
-                    href={item.href}
-                    aria-current={isActive ? 'page' : undefined}
-                    className={cn(
-                      'flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm transition-colors',
-                      isActive
-                        ? 'bg-primary/10 text-primary font-medium'
-                        : isLocked
-                          ? 'text-muted-foreground/50 hover:bg-muted/50 hover:text-muted-foreground'
-                          : 'text-muted-foreground hover:bg-muted hover:text-foreground'
-                    )}
-                  >
-                    <Icon className="h-4 w-4 shrink-0" />
-                    <div className="min-w-0 flex-1">
-                      <div className="flex items-center gap-2">
-                        {/* Two lines at most: a long title wraps instead of being cut. */}
-                        <p className={cn('line-clamp-2 min-w-0', isActive && 'font-medium')}>
-                          {t(`nav.items.${item.key}.title`)}
-                        </p>
-                        {isLocked && (
-                          <span className="shrink-0 rounded bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-amber-600">
-                            {t('nav.pro')}
-                          </span>
-                        )}
-                        {newPill(item)}
-                      </div>
-                      <p className="hidden text-xs text-muted-foreground lg:line-clamp-2">
-                        {t(`nav.items.${item.key}.description`)}
-                      </p>
-                    </div>
-                  </Link>
-                )
-              })}
-            </div>
-          </div>
-        )
-      })}
-    </nav>
+    <SettingsSearch features={features} isCloud={isCloud} supportEnabled={supportEnabled}>
+      <TooltipProvider delayDuration={500}>
+        <nav ref={navRef} className="flex flex-col gap-4 pt-1">
+          {SETTINGS_CATEGORIES.map((category) => {
+            const visibleItems = pages.filter((p) => p.category === category)
+            if (visibleItems.length === 0) return null
+            return (
+              <div key={category}>
+                <p className="mb-1 px-3 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground">
+                  {t(`nav.categories.${category}`)}
+                </p>
+                <div className="flex flex-col gap-0.5">
+                  {visibleItems.map((item) => {
+                    const isActive = pathname === item.href
+                    const isLocked = !!(item.gate && features && !features[item.gate])
+                    const Icon = SETTINGS_PAGE_ICONS[item.key]
+                    return (
+                      // What the page is for, on hover and on keyboard focus.
+                      <Tooltip key={item.href}>
+                        <TooltipTrigger asChild>
+                          <Link
+                            href={item.href}
+                            aria-current={isActive ? 'page' : undefined}
+                            className={cn(
+                              // Room above for the search box that stays on top.
+                              'group flex min-h-8 scroll-mt-12 items-center gap-2.5 rounded-lg px-3 py-1.5 text-sm transition-colors',
+                              isActive
+                                ? 'bg-primary/10 font-semibold text-primary'
+                                : isLocked
+                                  ? 'text-muted-foreground/70 hover:bg-muted/50 hover:text-muted-foreground'
+                                  : 'text-foreground hover:bg-muted'
+                            )}
+                          >
+                            <Icon
+                              className={cn(
+                                'h-4 w-4 shrink-0',
+                                !isActive && 'text-muted-foreground group-hover:text-foreground'
+                              )}
+                            />
+                            {/* Two lines at most: a long title wraps instead of being cut. */}
+                            <span className="line-clamp-2 min-w-0 flex-1">
+                              {t(`nav.items.${item.key}.title`)}
+                            </span>
+                            {isLocked && (
+                              <span className="shrink-0 rounded bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-amber-600">
+                                {t('nav.pro')}
+                              </span>
+                            )}
+                            {newPill(item)}
+                          </Link>
+                        </TooltipTrigger>
+                        <TooltipContent side="right">
+                          {t(`nav.items.${item.key}.description`)}
+                        </TooltipContent>
+                      </Tooltip>
+                    )
+                  })}
+                </div>
+              </div>
+            )
+          })}
+        </nav>
+      </TooltipProvider>
+    </SettingsSearch>
   )
 }