Skip to content

fix: allow editor focus when project search drawer is open#557

Merged
jacobgkau merged 1 commit intopop-os:masterfrom
layer78:fix/project-search-focus
Apr 10, 2026
Merged

fix: allow editor focus when project search drawer is open#557
jacobgkau merged 1 commit intopop-os:masterfrom
layer78:fix/project-search-focus

Conversation

@layer78
Copy link
Copy Markdown

@layer78 layer78 commented Apr 10, 2026

Focus gets stuck on the project search input when using "Find in project".
After clicking a search result or clicking the editor text area, typing
still goes to the search box instead of the editor.

The root cause is update_focus() unconditionally focusing the project
search input whenever the context drawer is open on the ProjectSearch page.
Unlike the Find bar which has a has_focus flag to allow focus to return
to the editor, the project search had no equivalent mechanism.

This adds a project_search_has_focus flag mirroring the existing Find bar
pattern:

  • Set true when opening the search drawer, typing in the search input,
    or receiving search results
  • Set false when clicking a search result or clicking the editor
  • update_focus() only focuses the search input when the flag is true

Steps to reproduce (before fix):

  1. Open a project
  2. Edit -> Find in project...
  3. Search for something
  4. Click a result
  5. Click in the editor text area
  6. Start typing — input goes to the search box instead of the editor
  • I have disclosed use of any AI generated code in my commit messages.
  • I understand these changes in full and will be able to respond to review comments.
  • My change is accurately described in the commit message.
  • My contribution is tested and working as described.
  • I have read the Developer Certificate of Origin and certify my contribution under its conditions.

@jacobgkau jacobgkau requested review from a team April 10, 2026 17:32
@jacobgkau jacobgkau force-pushed the fix/project-search-focus branch from 067a614 to 2d25f10 Compare April 10, 2026 18:44
@jacobgkau jacobgkau self-assigned this Apr 10, 2026
@jacobgkau jacobgkau linked an issue Apr 10, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Member

@jacobgkau jacobgkau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed this fixes focus with the project search drawer open. Thank you for the fix!

Regression testing passed:

Basic operations

  • Type three lines of text (no trailing newline).
  • Copy the last two lines.
  • Paste at the end of the third line (file should now have four lines).
  • Ctrl-Z to undo the paste.
  • Press Enter to add a trailing newline.
  • Paste again (file should now have five lines).
  • Ctrl-Z to undo the paste.
  • Ctrl-Shift-Z to redo the paste.
  • Save the file.
  • Ctrl-F and search for something that has a match.
  • Press Esc twice to exit the Find dialog.
  • Press Ctrl-X to cut the selected search result.
  • Paste the cut text on a new line (file should now have six lines).
  • Re-save the file.
  • Narrow the window until the lines start wrapping (make a line longer if necessary to observe line wrapping).
  • Turn word wrapping off.
  • Scroll right to the end of the document, then left to the beginning again.
    • Active line highlight stops after visible part scrolls; not a regression.
  • Click and drag to select some text past the horizontal edge of the window.
  • Close the file, open COSMIC Edit again, and open the file via the recents list.
    • Doesn't show up; not a regression: #460
  • Close the file again, open COSMIC Edit again, and open the file via the Open dialog.
  • Turn word wrapping back on.

Settings

  • Open View -> Settings.
  • All Appearance settings work.
  • Vim bindings work.

Projects & Git Management

  • Clone the cosmic-edit Git repo and open its directory as a project.
  • Edit -> Find in project... works.
  • Make a change in a file.
  • File -> Git management shows the change and staging it works.
  • Make another change while Git management's open; it updates to show the new change.
  • Un-staging a change works.

Additional Usage

  • Open a large file (e.g. sudo dmesg > dmesg.txt), click and drag to select all of its text, cut, and paste.

@jacobgkau jacobgkau merged commit ffb2c46 into pop-os:master Apr 10, 2026
10 checks passed
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.

Unable to type after find-in-project (until project search is closed)

3 participants