Fix: Auto-activate first section and auto-focus first element on register

- When first focusable component registers, auto-activate its section
- First element in active section auto-focuses (macOS/SwiftUI behavior)
- Enables Tab navigation between groups from the start
- All 591 tests passing
This commit is contained in:
phranck
2026-02-06 18:14:26 +01:00
parent 6fee5aa671
commit 58ad43c6ea
+4 -1
View File
@@ -168,7 +168,10 @@ public extension FocusManager {
guard let section = section(id: targetID) else { return }
section.register(element)
// Auto-focus first element in the active section
// Auto-activate section and auto-focus first element if needed
if activeSectionID == nil {
activeSectionID = targetID
}
if targetID == activeSectionID && focusedID == nil && element.canBeFocused {
focus(element)
}