How to avoid performing a push navigation in swiftUI

I have a swiftUI listView. Each row includes details about a model object, and a button to perform a specific action in the row.
Code Block
struct EpisodeRowView: View {
    @ObservedObject var episode: Episode
    var body: some View {
        HStack {
            if shouldShowRightButton() {
                Button(action: {
                    self.handleRightButtonTap()
                }) {
                    rightButtonImage()
                }
                .padding(.horizontal)
            }
            NavigationLink(destination: EpisodeDetailView(episode: episode)) {
                Text(episode.title)
            }
        }
    }

Unfortunately when I tap the button it performs the push to the navigation destination.
Is there some way I can prevent/disable this unwanted push?
thanks,
Mike

Replies

You could implement a tap gesture on your button
Code Block import SwiftUI
struct ContentView: View {
    var body: some View {
        NavigationView {
        List {
            ForEach(0..<10) { index in
                NavigationLink(
                    destination: DetailsView(),
                    label: {
                        HStack (spacing: 12) {
                            Text("\(index)")
                                .padding()
                            Menu {
                                Button("Order Now", action: {})
                                Button("Adjust Order", action: {})
                                Button("Cancel", action: {})
                                Divider()
                                Menu {
                                    Button("Rename", action: {})
                                    Button("Delay", action: {})
                                } label: {
                                    Label("Nested", systemImage: "paperplane")
                                }
                            } label: {
                                Label("Menu", systemImage: "paperplane")
                            }
                            .foregroundColor(Color(.systemPink))
                            .padding(.horizontal)
                            .padding(.vertical, 10)
                            .overlay(
                                RoundedRectangle(cornerRadius: 12)
                                    .stroke(Color(.systemPink), lineWidth: 1)
                            )
                            Button(action: {
                                // Do something
                                print("Button Tapped \(index)")
                            }, label: {
                                Text("Button")
                                    .foregroundColor(Color(.systemPink))
                            })
                            .padding()
                            .onTapGesture(count: 1, perform: {
                                print("Button Tapped \(index)")
                            })
                        }
                })
                    .isDetailLink(false)
            }
        }
        .navigationTitle("Testing")
        }
    }
}
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
struct DetailsView: View {
    var body: some View {
        Text("You are in details view")
    }
}