Skip to content

fix(settings): put focus back in the search box when Settings closes - #166

Merged
grimmerk merged 1 commit into
mainfrom
fix-settings-close-refocus
Oct 23, 2026
Merged

grimmerk merged 1 commit into
mainfrom
fix-settings-close-refocus

Conversation

@grimmerk

@grimmerk grimmerk commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closing the Settings panel now puts the cursor back in the current tab's search box, so typing searches again right away.

The bug

  1. Open Settings with the Settings button. Focus moves into the panel (expected — the panel's focus trap holds it there while it is open).
  2. Close it with the same button. Focus stayed on the button, so typing searched nothing until you clicked a row, or switched to another app and back.

Why: the switcher refocuses the search box on any click, except clicks inside the Settings panel, so it never steals focus from the panel's dropdowns. The Settings button is marked as part of the panel, so the click that closes it was skipped too.

Leaving the app and coming back while the panel is open behaved the same way, and for the same reason: the focus trap kept focus in the panel, and after closing it, the button kept it.

The fix

PopupDefaultExample (src/popup.tsx) takes an onClosed callback and calls it when the panel goes from open to closed; the switcher passes forceFocusOnInput, which focuses the current tab's search box (and leaves the Term tab alone, as before). The call is deferred with a 0 ms timeout so that it runs after the focus trap's own deferred focus return (focus-trap 2.4.6 returns focus with setTimeout(…, 0) on deactivate); otherwise the trap could put focus back on the button.

Testing

  • npx tsc --noEmit clean; npx vitest run 222/222.
  • No unit test: this is focus behaviour inside Electron, which the test setup does not render.
  • Tested by hand in a yarn start build: close Settings on the Sessions tab and on the Projects tab, then type — the search filters. Open Settings, switch to another app and back, close Settings, type — the search filters.

CHANGELOG: one Fix line under the unreleased 1.0.94.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Closing Settings now returns focus to the current tab’s search box, making it easier to continue searching.
    • Closing the switcher popup now returns focus to its input.

The Popup's focus trap holds focus in the panel while it is open.
Closing it with the Settings button left focus on that button, and
the switcher's click-to-refocus skips it because the button is marked
as part of the panel, so typing went nowhere until another click.
The panel now calls onClosed after it closes, deferred past the
trap's own deferred focus return.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 737089ad-60c9-4f38-bdf9-d1443e264ba4
📥 Commits

Reviewing files that changed from the base of the PR and between 0aad973 and 7ed49f5.

📒 Files selected for processing: 3
  • CHANGELOG.md
  • src/popup.tsx
  • src/switcher-ui.tsx

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The popup now supports an optional callback after it closes. The switcher uses this callback to return focus to its input. The changelog records the focus behavior for Settings.

Changes: Settings close focus

Layer / File(s) Summary
Popup close callback
src/popup.tsx
PopupDefaultExample accepts an optional onClosed callback. When the popup transitions from open to closed, it schedules the callback with a zero-delay timeout and cancels the timeout during effect cleanup.
Switcher focus wiring
src/switcher-ui.tsx, CHANGELOG.md
The switcher passes forceFocusOnInput as onClosed. The changelog records that closing Settings returns focus to the current tab’s search box.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 7ed49

The Settings close behavior is supported by the reviewed implementation and presents no identified merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: refocusing the search box when Settings closes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.

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.

@grimmerk
grimmerk merged commit 471aab4 into main Oct 23, 2026
2 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.

1 participant