Repository navigation
fix(settings): put focus back in the search box when Settings closes - #166
Conversation
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>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
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
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 anonClosedcallback and calls it when the panel goes from open to closed; the switcher passesforceFocusOnInput, 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-trap2.4.6 returns focus withsetTimeout(…, 0)on deactivate); otherwise the trap could put focus back on the button.Testing
npx tsc --noEmitclean;npx vitest run222/222.yarn startbuild: 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