SwiftUI FocusState seems to 'misbehave' when Scene contains a DocumentGroup...

I have a view containing either a TextField or a SecureField. I'm hoping I can use a single FocusState value that will apply to either the TextField or SecureField. (I'm using FocusState to ensure the cursor will be in the field when it initially loads) I've verified this works in a sample project when the view is in a WindowGroup. But when I instead use a DocumentGroup ~50% of the time when the view loads/launches, it does not have focus.

Here is my ContentView:

struct ContentView: View {
    let coinFlip: Bool = .random() // used to choose between the TextField and the SecureField
    @State var fieldContent: String = "" // bound to the Field value
    @FocusState var focus: Bool
    
    var body: some View {
        VStack {
            Text("Coin Flip: \(coinFlip)")
            actualField
                .focused($focus, equals: true)
        }
        .onAppear() {
            focus = true
        }
    }
    @ViewBuilder var actualField: some View {
        if coinFlip {
            TextField("Enter text here", text: $fieldContent)
        } else {
            SecureField("Enter secure text here", text: $fieldContent)
        }
    }
}

and here is my App swift file

@main
struct ModernTurtleApp: App {
    var body: some Scene {
//        WindowGroup {
//            ContentView()
//        }
        DocumentGroup(newDocument: ModernTurtleDocument()) { file in
            ContentView()
        }
    }
}

When this code runs, the Field has focus about 50% of the time on initial launch. When I uncomment the WindowGroup and comment the DocumentGroup, the field always has focus on initial launch.

I realize I can work around this behaviour by using an optional enum for FocusState. I would be ok going this route, but I first want to try to understand the behaviour I'm seeing, and possibly keep my simpler FocusState implementation. Thanks, in advance for any help.

SwiftUI FocusState seems to 'misbehave' when Scene contains a DocumentGroup...
 
 
Q