Menu bar and Help window

by selecting Help under my Help menu item or cmd-h no window appears until the menu bar is touched.

myApp.swift file:

import SwiftUI
import QuickLook

@main
struct myApp: App {
 
 @Environment(\.openWindow) var openWindow
 @State var helpURL: URL? = nil
 
 var body: some Scene {
  
  WindowGroup {
   ContentView()
  }
  .commandsReplaced {
   CommandGroup(before: .appInfo) {
    Button("Quit") {
     NSApp.terminate(nil)
    }.keyboardShortcut("q")
   }
   
   CommandGroup(before: .help) {
    //FIXME: only shows help if the menu bar is touched again.
    Button("Help") {
     helpURL = Bundle.main.url(forResource: "help", withExtension: "txt")
    }
    .keyboardShortcut("h")
    .quickLookPreview($helpURL)
   }
  }
 }
}

How should this be coded for proper action? Thanks

Answered by G.U.T.explorer in 848384022

Solved: moved line 30 to 16

Accepted Answer

Solved: moved line 30 to 16

Menu bar and Help window
 
 
Q