From 58ad43c6ea60ef19eac513581f8a87df2576e7dd Mon Sep 17 00:00:00 2001 From: phranck Date: Fri, 6 Feb 2026 18:14:26 +0100 Subject: [PATCH] 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 --- Sources/TUIkit/Focus/Focus.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/TUIkit/Focus/Focus.swift b/Sources/TUIkit/Focus/Focus.swift index 132e932..70f1b3a 100644 --- a/Sources/TUIkit/Focus/Focus.swift +++ b/Sources/TUIkit/Focus/Focus.swift @@ -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) }