0.1 C
New York
Sunday, March 9, 2025

ios – NavigationLink not working after leaving view


I am experiencing a bug that does not permit me to go away a view after returning to it. It appears to occur 1/8 occasions reproducing it.

the deal with view, after deciding on a location returns to the earlier display screen which works fantastic.

struct AddressView: View {
    @Atmosphere(.dismiss) var dismiss
    @StateObject personal var viewModel = AddressViewModel()
    @FocusState personal var isFocusedTextField: Bool
    
    @Binding var selectedBusinessName: String
    @Binding var selectedPhoneNumber: String
    @Binding var selectedBusinessAddress: String
    
    var physique: some View {
        NavigationStack {
            VStack(alignment: .main, spacing: 0) {
                TextField("Search...", textual content: $viewModel.searchableText)
                    .padding()
                    .autocorrectionDisabled()
                    .centered($isFocusedTextField)
                    .font(.title)
                    .onReceive(
                        viewModel.$searchableText.debounce(
                            for: .seconds(1),
                            scheduler: DispatchQueue.primary
                        )
                    ) {
                        viewModel.searchAddress($0)
                    }
                    .background(Shade(uiColor: .systemBackground))
                    .overlay {
                        ClearButton(textual content: $viewModel.searchableText)
                            .padding(.trailing)
                            .padding(.prime, 8)
                    }
                    .onAppear {
                        isFocusedTextField = true
                    }
                Listing(viewModel.outcomes) { deal with in
                    AddressRow(
                        deal with: deal with,
                        printPhoneNumber: { deal with in
                            Activity { @MainActor in
                                if let phoneNumber = strive await viewModel.fetchPhoneNumber(for: deal with) {
                                    selectedBusinessName = deal with.title
                                    selectedPhoneNumber = phoneNumber
                                    selectedBusinessAddress = deal with.subtitle
                                    dismiss()
                                } else {
                                    print("No telephone quantity out there")
                                }
                            }
                        },
                        dismiss: {
                            dismiss()
                        }
                    )
                    .listRowBackground(backgroundColor)
                }
                .listStyle(.plain)
                .scrollContentBackground(.hidden)
            }
            .background(backgroundColor)
            .edgesIgnoringSafeArea(.backside)
        }
    }
    
    var backgroundColor: Shade = .init(uiColor: .systemGray6)
}

now right here is the place I can not truly depart the view making an attempt press the highest left Navlin.

    var physique: some View {
        VStack {
            ScrollViewReader { proxy in
                Type {
                    Part(header: Textual content("location")) {
                        NavigationLink("Search", vacation spot: AddressView(selectedBusinessName: $selectedBusinessName, selectedPhoneNumber: $selectedBusinessPhoneNumber, selectedBusinessAddress: $selectedBusinessAddress))
                    }
    

issue

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles