Skip to content

Commit c8ff3cb

Browse files
authored
Merge pull request #71 from grimmerk/fix/arrow-key-focus-on-return
fix: re-focus search input on window return
2 parents 4055339 + c746f60 commit c8ff3cb

4 files changed

Lines changed: 22 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 1.0.46
4+
5+
- Fix: arrow keys not changing selected item after returning from background
6+
- Fix: Settings panel close not returning focus to correct search input (React closure trap)
7+
38
## 1.0.45
49

510
- cmux: three-layer switch matching (title → TTY → cwd fallback), same as iTerm2

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "CodeV",
33
"productName": "CodeV",
4-
"version": "1.0.45",
4+
"version": "1.0.46",
55
"description": "Quick switcher for VS Code, Cursor, and Claude Code sessions",
66
"main": ".webpack/main",
77
"scripts": {

src/popup.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ const PopupDefaultExample = ({
131131
placement="bottom-end"
132132
content={(props) => (
133133
<div
134+
data-settings-panel
134135
style={{
135136
width: 500,
136137
backgroundColor: '#252525',
@@ -511,6 +512,7 @@ const PopupDefaultExample = ({
511512
trigger={(triggerProps) => (
512513
<Button
513514
{...triggerProps}
515+
data-settings-panel
514516
appearance="primary"
515517
isSelected={isOpen}
516518
onClick={() => {

src/switcher-ui.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,10 @@ function SwitcherApp() {
303303
const ref = useRef(null);
304304
const sessionSearchRef = useRef<HTMLInputElement>(null);
305305
const forceFocusOnInput = () => {
306-
if (mode === 'projects') {
307-
ref.current?.focus();
308-
} else {
306+
if (modeRef.current === 'sessions') {
309307
sessionSearchRef.current?.focus();
308+
} else {
309+
ref.current?.focus();
310310
}
311311
};
312312

@@ -451,6 +451,9 @@ function SwitcherApp() {
451451
document.addEventListener('keydown', handleKeyDown);
452452
document.addEventListener('keyup', handleKeyUp);
453453
document.addEventListener('click', (e) => {
454+
// Don't steal focus from Settings panel interactions (dropdowns, buttons, etc.)
455+
const target = e.target as HTMLElement;
456+
if (target.closest('[data-settings-panel]')) return;
454457
forceFocusOnInput();
455458
});
456459

@@ -464,6 +467,14 @@ function SwitcherApp() {
464467
(window as any).electronAPI.getSessionDisplayMode().then((mode: string) => {
465468
setSessionDisplayMode(mode || 'first');
466469
});
470+
// Re-focus search input so arrow keys work (not captured by scroll container)
471+
setTimeout(() => {
472+
if (modeRef.current === 'sessions') {
473+
sessionSearchRef.current?.focus();
474+
} else {
475+
ref.current?.focus();
476+
}
477+
}, 50);
467478
});
468479

469480
(window as any).electronAPI.onWorkingFolderIterated(

0 commit comments

Comments
 (0)