0

I have a simple test watchOS application with a TextField in a secondary view (navigated to from a NavigationLink). However, when the TextField is canceled or submitted, it will pop back out to the root view instead of staying in the current view. I can't find any information on this anywhere else. Any fixes?

ContentView:

import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationView{
            NavigationLink("what", destination: DestinationView())
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

DestinationView:

import SwiftUI

struct DestinationView: View {
    @State private var message: String = ""

    var body: some View {
        TextField(
                "Send Something...",
                text: $message
            )
    }
}

struct DestinationView_Previews: PreviewProvider {
    static var previews: some View {
        DestinationView()
    }
}
pycoder
  • 1
  • 3
  • Not seeing that behavior here. iOS 16, Xcode 14b2. What OS are you using? Also, there is no cancel implemented. What do you mean be "cancel"? – Yrb Jun 23 '22 at 23:43
  • @Yrb I’m using watchOS, where there is a cancel button. – pycoder Jun 23 '22 at 23:51

1 Answers1

0

I found the issue..

I was using a NavigationView, which is deprecated. I removed it and now it's working as intended. (XCode 13.2.1, watchOS 8.3)

*facepalm*

pycoder
  • 1
  • 3