Skip to content

Code editor search bar (Cmd+F) does not select existing text on re-open, causing typed input to append#7919

Open
anirtek wants to merge 1 commit intousebruno:mainfrom
anirtek:bugfix/response-search-focus
Open

Code editor search bar (Cmd+F) does not select existing text on re-open, causing typed input to append#7919
anirtek wants to merge 1 commit intousebruno:mainfrom
anirtek:bugfix/response-search-focus

Conversation

@anirtek
Copy link
Copy Markdown

@anirtek anirtek commented May 6, 2026

I have checked the following:

  • I have searched existing issues and found nothing related to my issue.

This bug is:

  • annoying

Bruno version

<your version, e.g. 3.3.0>

Operating System

macOS 26.3.1 (a)

Describe the bug

In the Response pane (and any CodeEditor surface — request body, pre/post-request scripts, tests editor) the custom search bar (CodeMirrorSearch) does not select its existing text when re-opened with Cmd+F / Ctrl+F.

The component preserves searchText state across open/close cycles, and on re-open the input is re-focused but the caret lands at the end of the existing query. Typing new characters then appends to the old query instead of replacing it.

This diverges from native browser and IDE search-bar behavior (Chrome's Cmd+F, VS Code, etc., all pre-select the existing query on re-open).

Steps to reproduce

  1. Open any collection and send a request that returns a non-trivial response body.
  2. Click into the Response pane and press Cmd+F (macOS) / Ctrl+F (Win/Linux).
  3. Type item_1.
  4. Press Esc to dismiss the search bar.
  5. Press Cmd+F / Ctrl+F again.
  6. Type item_2.

Expected: Step 5 selects the existing item_1 so step 6 replaces it. The search input reads item_2.

Actual: Step 5 places the caret at the end of item_1. Step 6 appends, producing item_1item_2.

Affected surfaces

The bug reproduces in every CodeEditor instance, since they all share CodeMirrorSearch:

  • Response pane
  • Request body editor
  • Pre-request / post-request script editors
  • Tests editor

.bru file to reproduce the bug

Not required — reproducible against any request that returns a body.

Proposed fix

In packages/bruno-app/src/components/CodeMirrorSearch/index.js, the imperative focus() exposed via useImperativeHandle only calls inputRef.current.focus(). Adding inputRef.current.select() immediately after it makes the existing search term selected on every re-open via the keyboard shortcut.

PR: #7919

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 6, 2026

Walkthrough

The change adds a single line to auto-select the search input text when the CodeMirrorSearch component receives focus via its imperative handle, improving keyboard navigation and user experience during search workflows.

Changes

Search Input Focus Enhancement

Layer / File(s) Summary
Focus Behavior
packages/bruno-app/src/components/CodeMirrorSearch/index.js
The imperative focus() method now calls inputRef.current.select() after inputRef.current.focus(), automatically selecting all text in the search input when it gains focus.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • usebruno/bruno#6980: Modifies the same imperative focus method in CodeMirrorSearch, directly related to focus behavior management.

Suggested reviewers

  • helloanoop
  • bijin-bruno
  • lohit-bruno
  • naman-bruno

Poem

🔍 A single line, so small yet keen,
Selects your text with focused grace—
No more fumbling in between,
Search finds its rightful place! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The PR partially addresses the linked issues. It fixes the auto-select behavior for the search bar opening, but the primary objectives in #7833 and #7904 focus on preventing cross-triggering of search shortcuts across panes, which this change alone does not fully resolve. Verify that shortcut interception logic has been separately addressed to prevent Ctrl+F/Cmd+F from triggering collection search when focus is in message/response body panes.
✅ Passed checks (4 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The change is narrowly scoped to adding select() in the CodeMirrorSearch focus method, which is directly related to the UX improvement described in the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main fix: auto-selecting existing text in the search bar when reopened to prevent typed input from appending instead of replacing.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@anirtek anirtek changed the title fix: auto-select existing text when opening code editor search bar Code editor search bar (Cmd+F) does not select existing text on re-open, causing typed input to append May 6, 2026
@anirtek
Copy link
Copy Markdown
Author

anirtek commented May 8, 2026

@helloanoop can I get some reviews on this MR?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant