Skip to content

feat: consistent focus ring and reliable focus restoration - #108

Merged
nextestudios merged 1 commit into
mainfrom
feature/31-focus-restoration
Sep 27, 2026
Merged

nextestudios merged 1 commit into
mainfrom
feature/31-focus-restoration

Conversation

@nextestudios

Copy link
Copy Markdown
Owner

Summary

  • Focus ring token: Theme.ApplyFocus (3 px accent border + soft fill) is used by list rows, menus and dialogs; the on-screen keyboard already uses the same tokens. The ListView's native selection highlight is turned off (SelectionMode.None) so there is exactly one focus visual. Cut rows dim their content, not the ring.
  • Restoration after deletes/refreshes: FileListState.SetItems now moves focus to the next item that survived in the previous order (else the previous one) when the focused item disappears. Before, it reused the old index, which skipped a survivor after deleting several marked items (regression test in StateTests).
  • Scroll into view before the transition completes: when a folder's items change, the list is measured (UpdateLayout) and scrolled to the focused item before the first frame; focus moves only restyle the two affected containers.
  • After modals: if the focused XAML element left the tree when the overlay was rebuilt, the root takes focus back so the physical keyboard never goes dead. Menus with zero items can only be closed (previously % 0 would throw).

Testing

  • CI: unit tests, including the new Deleting_marked_items_moves_focus_to_the_next_survivor_not_the_same_index.
  • Manual (added to docs/TESTING.md): ring legibility at TV distance/4K, keyboard still responsive after closing menus/dialogs (incl. mouse click on an option), focus after multi-delete in a large folder, focus visible on the first frame after Back in a folder with thousands of items.

Closes #31

🤖 Generated with Claude Code

@nextestudios
nextestudios force-pushed the feature/31-focus-restoration branch 2 times, most recently from f498670 to 16a80c7 Compare September 27, 2026 02:43
- One focus token (Theme.ApplyFocus) for list rows, menus and dialogs; the
  ListView's native selection highlight is off so there is a single ring.
- When the focused item disappears (delete, move, external change), focus
  moves to the next surviving item in the previous order, else the previous
  one. Fixes focus skipping a survivor after deleting several marked items.
- Opening a folder measures the list and scrolls the focused item into view
  before the first frame; moving focus only restyles the two affected rows.
- After a modal closes, keyboard focus returns to the root if the focused
  XAML element left the tree; empty menus can no longer divide by zero.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nextestudios
nextestudios force-pushed the feature/31-focus-restoration branch from 16a80c7 to f737a91 Compare September 27, 2026 02:45
@nextestudios
nextestudios merged commit a9d75ef into main Sep 27, 2026
1 check passed
@nextestudios
nextestudios deleted the feature/31-focus-restoration branch September 27, 2026 02:47
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.

enhancement: improve controller focus visuals and focus restoration

1 participant