youjin
youjin

Reputation: 2549

NavigationLinks stay highlighted when using both `.background` and `VStack`

The navigation link in the following code stays highlighted even when the navigation is popped.

Comment out one of the two and it works as expected.

Tested with iOS 14 beta 6 and Xcode 12 beta 6

struct ContentView: View {
    var body: some View {
        NavigationView {
            VStack {
                List {
                    NavigationLink(destination: Text("B")) {
                        Text("A")
                    }
                }
                Text("Bottom")                   // <- this 
            }
            .background(Text("Hi"))             // <- and this
        }
    }
}

Upvotes: 1

Views: 282

Answers (1)

dimiandre
dimiandre

Reputation: 71

This happen also to me when text is on top, weird

struct ContentView: View {

    var body: some View {
        NavigationView {
           VStack {
               Text("Top") // <- this
               List {
                   NavigationLink(destination: Text("B")) {
                       Text("A")
                   }
               }
                              
           } 
       }
    }
}

Upvotes: 1

Related Questions