Skip to content

[Repo Assist] Improve search UX: auto-focus, consistent close, Ctrl+K shortcut#1084

Draft
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/improve-search-ux-d009669d33ef160e
Draft

[Repo Assist] Improve search UX: auto-focus, consistent close, Ctrl+K shortcut#1084
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/improve-search-ux-d009669d33ef160e

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 9, 2026

🤖 This is an automated PR from Repo Assist.

Summary

Three small but meaningful improvements to the fsdocs search dialog in fsdocs-search.js:

1. Auto-focus search input on open

Previously, opening the search dialog required an extra click to focus the input before typing. Now searchBox.focus() is called immediately after showModal(), so typing works instantly.

2. Consistent close behaviour

The "click backdrop to close" path already cleared searchBox.value. The Escape-key path did not — leaving the previous search term in the box when the dialog was reopened. This PR extracts a closeSearch() helper that resets the input value, clears results, and closes the dialog — used by both close paths.

Additionally, Escape handling is moved from keyup to keydown so ev.preventDefault() reliably stops the browser's built-in (dialog) close event before our custom reset logic runs.

3. Ctrl+K / Cmd+K keyboard shortcut

/ remains supported. Ctrl+K / Cmd+K is now also accepted, matching the convention used by GitHub, MDN, VS Code, and many modern documentation sites. The / shortcut is suppressed when the cursor is in an (input) or (textarea) to avoid accidentally opening search mid-sentence.

Files changed

  • docs/content/fsdocs-search.js — logic changes described above
  • RELEASE_NOTES.md — changelog entry under [Unreleased]

Test Status

These are pure JavaScript changes to a client-side script; there are no unit tests for JS in this repo.

  • dotnet build FSharp.Formatting.sln --configuration Release — succeeded (no F# changes)
  • dotnet test FSharp.Formatting.sln --configuration Release --no-build — all tests pass (no F# changes)
  • dotnet fantomas build.fsx src tests docs --check — no issues (Fantomas only checks F#/FSX files)

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

- openSearch() focuses the search input immediately after showModal()
- closeSearch() resets the input value and clears results on every close path
  (backdrop click, Escape, or future programmatic close), making behaviour
  consistent regardless of how the dialog was dismissed
- Keyboard shortcut: Ctrl+K / Cmd+K (in addition to '/') now opens search,
  matching the convention used by GitHub, MDN, and many modern doc sites
- The '/' shortcut is now suppressed when the user is typing in an INPUT or
  TEXTAREA to avoid accidentally opening search mid-sentence
- Escape handling moved from keyup to keydown so ev.preventDefault() reliably
  stops the browser's built-in dialog-close before our custom close logic runs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants