[Repo Assist] Improve search UX: auto-focus, consistent close, Ctrl+K shortcut#1084
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Draft
[Repo Assist] Improve search UX: auto-focus, consistent close, Ctrl+K shortcut#1084github-actions[bot] wants to merge 2 commits intomainfrom
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
- 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>
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 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 aftershowModal(), 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 acloseSearch()helper that resets the input value, clears results, and closes the dialog — used by both close paths.Additionally, Escape handling is moved from
keyuptokeydownsoev.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+Kis 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 aboveRELEASE_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)