Skip to content

fix(desktop): select the query when re-opening the Find bar - #4807

Merged
Jocs merged 1 commit into
developfrom
fix/3458-find-select-on-reopen
Jul 2, 2026
Merged

Jocs merged 1 commit into
developfrom
fix/3458-find-select-on-reopen

Conversation

@Jocs

@Jocs Jocs commented Jul 1, 2026

Copy link
Copy Markdown
Member

Problem

Re-pressing Find (Cmd/Ctrl-F) while the find bar was already open just re-focused the input, leaving the caret after the existing search term. The next keystroke appended to the old term instead of replacing it ("accretion").

Root cause

listenFind() calls search.value?.focus() but never select(), so a re-open lands a collapsed caret at the end of the populated input.

Fix

Call search.value?.select() right after focusing, so the current term is highlighted and a keystroke types over it (harmless when the input is empty).

Test

packages/desktop/test/e2e/find-reopen-select-3458.spec.ts (real built app): type a query, re-trigger Find, assert the whole term is selected (selectionStart=0, selectionEnd=len) and that typing replaces it. Verified RED→GREEN; existing find-replace.spec.ts still passes.

Fixes #3458

🤖 Generated with Claude Code

Re-pressing Find (Cmd/Ctrl-F) while the bar was already open only re-focused
the input, leaving the caret after the existing term so the next keystroke
appended to it. Select the input's contents after focusing so the current
term is highlighted and a keystroke types over it.

Fixes #3458

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Build artifacts for PR #4807:

Run: https://github.com/marktext/marktext/actions/runs/28499293907

Artifact Size Link
marktext-windows-arm64 275.7 MB Download
marktext-linux 627.5 MB Download
marktext-windows-x64 283.8 MB Download
marktext-macos-x64 293.0 MB Download
marktext-windows-x64 283.8 MB Download
marktext-macos-arm64 282.7 MB Download

@Jocs
Jocs merged commit 3a76a0a into develop Jul 2, 2026
12 of 16 checks passed
@Jocs
Jocs deleted the fix/3458-find-select-on-reopen branch July 2, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Find panel behaviour wanting

1 participant