Skip to content

fix: restore article navigator focus when a rebuild removes the focused row - #189

Merged
Azganoth merged 1 commit into
mainfrom
bug/article-navigator-focus-restore
Aug 10, 2026
Merged

fix: restore article navigator focus when a rebuild removes the focused row#189
Azganoth merged 1 commit into
mainfrom
bug/article-navigator-focus-restore

Conversation

@Azganoth

Copy link
Copy Markdown
Owner

Summary

  • Restore focus to the row that inherits the tab stop when a rows rebuild unmounts the focused row. The tree records that it held focus on the row focus and blur handlers, because after the rebuild the element is gone and document.activeElement is already <body>.
  • Guard the restore so a background folder refresh cannot pull focus into the sidebar: it runs only when a row held focus and focus is actually orphaned on the document body.
  • No change to how the tab stop itself is resolved.

Related Issue

Closes #165

Verification

Three focused tests in article-navigator.test.tsx cover a rebuild that removes the focused row: focus and the tab stop land on the surviving ancestor row; focus parked on a control outside the navigator stays there; focus already on the document body is not claimed. Each was mutation-checked — removing the restore fails the first, removing the held-focus flag fails the third.

pnpm check:frontend.

Not verified: manual or desktop E2E runs. The unit tests run in happy-dom, which fires no focusout when the focused element unmounts — the behavior the restore depends on — so this has not been confirmed against a real WebView.

Notes

  • The document.activeElement === document.body clause is not required by any current test; it is kept so a rebuild that coincides with another surface taking focus (a dialog, say) cannot be overridden.
  • Out of scope per the issue: the reveal request that is never retired.

@Azganoth Azganoth self-assigned this Aug 10, 2026
@Azganoth Azganoth added the Bug Something isn't working label Aug 10, 2026
@Azganoth
Azganoth enabled auto-merge (squash) August 10, 2026 06:21
@Azganoth
Azganoth merged commit 56f2606 into main Aug 10, 2026
3 checks passed
@Azganoth
Azganoth deleted the bug/article-navigator-focus-restore branch August 10, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Article navigator focus is lost when a rows rebuild removes the focused row

1 participant