Skip to content

Keyboard shortcut "/" focuses the masthead search #26

Description

@NemboKid

The masthead search (components/NavSearch.tsx) is deliberately a plain method="get" form: no state, no router, no client bundle, works before hydration and with scripting off. This app ships exactly two client components (app/error.tsx and app/preflight/PreflightForm.tsx) and treats that as a feature. A "/" keyboard shortcut that focuses the search box is a genuinely useful affordance readers expect from directory-style sites, but it cannot exist without a little client JavaScript, so this issue is as much about where the line is as about the listener.

The line: progressive enhancement only. The form itself stays a server-rendered plain form; the shortcut is an additive layer whose absence changes nothing. The input already has a stable target, id="nav-q".

Where to look

  • components/NavSearch.tsx — the form, its "Why it is a plain form" doc comment (which must stay true, or be updated honestly), and id="nav-q"
  • app/error.tsx, app/preflight/PreflightForm.tsx — the two existing client components, for the prevailing style if a third is added
  • The layout that mounts the masthead, if the listener lives in a tiny separate client component rather than inside NavSearch

Done when

  • Pressing "/" outside a text field focuses the masthead search input
  • Typing "/" inside any input, textarea, select, or contenteditable element still types "/" — the listener ignores those targets, and ignores keystrokes with modifier keys held
  • With JavaScript disabled, nothing regresses: the form submits to /directory?q=… exactly as today
  • NavSearch.tsx remains a server component, with the shortcut in a minimal separate client affordance — or, if that proves worse, the doc comment and the "two client components" claim are updated to match reality
  • The doc comment explains the enhancement and the line it respects

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions