Textfield tap is dismissing navigation link in SwiftUI

Solution 1:

After some time of research I've found that NavigationLink closes because authViewPushed parameter in the viewModel becomes false. That happens because viewModel is being recreated because of firstView update. I've faced the same issue and here is the solution:

struct MyView: View {
    @StateObject var viewModel = MyViewModel()

    var body : some View {
        
    }
}

In this case MyView is being updated but MyViewModel remains the same.

Solution 2:

There seems to be an issue with iOS 14.5 and up where the tapping of any TextField inside a NavigationLink destination makes the view to pop out to the previous one.

There is a workaround thanks to @SeitenWerk and documented on the Apple Developer Forums

https://developer.apple.com/forums/thread/677333

The solution is simple. Just add an empty NavigationLink next to the one that fails. Interestingly, it logs "Unable to present. Please file a bug." on the debug console but makes things right with the usability of the app

NavigationLink(destination: LoginView()){
    Text("LOGIN")
}
NavigationLink(destination: EmptyView()) {
     EmptyView()
}

Remember to thank SeitenWerk on the Developer Forums.