'view display on the right of the window

hello i have an issue with my project on Xcode when I use navigation view, the window display not normally and appear on the right of the window already displayed,

here is the code.

NavigationLink(destination: Acceuil())
                        {
                            HStack{
                               Image("icone_connexion")
                                    .font(.system(size: 15))
                                 //   .scaledToFill()


                                Text("se connecter")
                                        .font(.system(size: 30))
                          
                            }.cornerRadius(60)
                           .frame(width: 400, height: 60)
                            
                        } .background(Capsule().fill(Color(red: 55/255, green: 66/255, blue: 114/255, opacity:1)))
                        .frame(width: 400, height: 60) //fin navigationlink
                        .buttonStyle(PlainButtonStyle())

I would like that the new window replace the older one:)



Solution 1:[1]

On macOS it is the standard behavior in NavigationView to show the views (parent view and destination view) next to each other: https://developer.apple.com/design/human-interface-guidelines/macos/windows-and-views/column-views/

If you don't want that you can do:

    NavigationView {
        ...
    }
    .navigationViewStyle(.stack)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ChrisR