Skip to content

fix(native): restore key window after modal panels - #431

Closed
tiensonqin wants to merge 2 commits into
native-parity-0.1-backportsfrom
devin/panel-focus-restore
Closed

tiensonqin wants to merge 2 commits into
native-parity-0.1-backportsfrom
devin/panel-focus-restore

Conversation

@tiensonqin

@tiensonqin tiensonqin commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fix keyboard-focus restoration after native macOS NSOpenPanel/NSSavePanel modal sessions. Previously the SDL host window could continue drawing a focused caret while the application itself remained inactive, so real keyboard input was dropped until the user clicked the window. After the modal session ends, the shell now explicitly reactivates the application and restores a visible key-capable non-panel window as key, for both accepted and cancelled panels.

docs/api-migrations.md records the behavior change; hosts require no source migration.

Validation

Real macOS SDL/Metal validation passed against this executable change in the Logseq native host. Primary acceptance: 0.5s after choosing a directory in the real macOS NSOpenPanel, typing noclick without clicking landed in the visibly focused New graph name input.

Before After
Before: typing after panel close did not land After: noclick lands immediately

Host evidence shows real key delivery and text mutation:

dom key down=true key=n target=406 identifier=-
dom keydown node=406 {"nodeId":406,"key":"n","code":"KeyN",...}
dispatch TextChanged node=406 class=form-input ls-prompt-input
...
dom key down=true key=k target=406 identifier=-
dom keydown node=406 {"nodeId":406,"key":"k","code":"KeyK",...}
dispatch TextChanged node=406 class=form-input ls-prompt-input

Regression/comparison checks:

  • Open-panel Cancel: passed; real keyboard input reached the app and t/l visibly toggled the sidebar.
  • Save-panel OK: passed; exported EDN completed and keyboard input reached the app without clicking.
  • Save-panel Cancel: host key events were delivered without clicking. The sidebar did not reopen while the Export dialog remained open, consistent with dialog-level shortcut ownership rather than focus loss.
  • No focus stealing or unexpected window ordering was observed.

Link to Devin session: https://app.devin.ai/sessions/4db1c451562249ac8356dbf66216a01b
Open in Devin Desktop: https://app.devin.ai/desktop/session/4db1c451562249ac8356dbf66216a01b?variant=devin
Requested by: @tiensonqin


🟢 Devin fixed the finding · Follow Devin's work

Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 finding. Devin automatically fixed it.

Fixed by Devin (1)
  • Main window overrides existing keyboard focus — Preserve an already eligible restored key window first, falling back to main/first only when the key window is absent, the closing panel, invisible, or cannot become key.

View findings in Devin Review · Follow Devin's work

Devin Review

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