Skip to content

Focus find-in-folder search box; unfocus with ESC #2294

Closed

Description

@MostFrabjous

When firing CmdOrCtrl+Shift+F the find-in-folder search box is shown in the sidebar, it is even prefilled with highlighted text, but it isn't focused.

This issue requests that the search box gets focussed after the shorcut is fired and is unfocussed if Escape is pressed, then the program should return to the state before the shorcut was fired.

This was also requested in #1311 and #1729

Activity

  1. Ziflin commented on May 10, 2022

    @Ziflin

    I definitely expect that pressing Ctrl+Shift+F would focus the search box in the same manner that pressing Ctrl+F focuses the search-in-page search box. This would also be consistent with VS Code, VS, etc. I keep finding myself pressing Ctrl+Shift+F and typing a search term only to find out that I've been typing in the document.

  2. added a commit that references this issue on Aug 21, 2022
    07a1afd
  3. added
    🦋 optimization
    on May 16, 2026
  4. self-assigned this
    on Oct 6, 2026
  5. Jocs commented on Oct 7, 2026

    @Jocs
    Member

    Re-verified against the current source and a locally built app, and checked what VS Code actually does. Summary:

    1. Focus on the shortcut — fixed.

    Pressing Cmd/Ctrl+Shift+F now focuses the sidebar search box. Driving the exact IPC the shortcut emits (mt::editor-edit-action / findInFolder) on a built app, document.activeElement becomes the .side-bar-search .search-input, and typed characters land in the box rather than the document.

    This came in with the electron-vite refactor (#4001): handleFindInFolder now calls searchEl.value.focus(), which the pre-refactor version did not do. So the "isn't focused" part of this issue is no longer reproducible.

    2. Unfocus on Esc — intentionally not changing it.

    Since this request cites VS Code as the reference, we checked the actual behaviour there:

    • In VS Code, Esc in the find-in-folder / Search view input does not blur the field. searchWidget's onSearchInputKeyDown fires _onSearchCancel.fire({ focus: true }), and searchView.cancelSearch(focus) calls searchWidget.focus(). So Esc only cancels an in-progress search and keeps focus in the box; there is no blur() anywhere in the search widget/view. Same code in 1.50 / 1.70 / 1.90 / current, and in the shipped 1.140.0 bundle.
    • The thing that closes on Esc in VS Code is the editor find widget (Ctrl/Cmd+F), not find-in-folder. MarkText already matches that via the find bar's Escape handling (components/search/index.vue).

    So keeping focus after Esc in find-in-folder is the VS Code-consistent behaviour, and we'll leave the current behaviour as-is.

    Closing, since the original "not focused" problem is resolved and the Esc behaviour matches VS Code. If we do want Esc to mean something here, the VS Code-aligned option would be to cancel the running search while keeping focus (optionally selecting the query), not to blur — happy to revisit in a separate issue if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🔭 area/ui🦋 optimization

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions