2

I have code with NavigationView and some NavigationLinks so one of them has toolbar modifier. My problem is that when I select first NavigationLink toolbar button act normally, but when I go to second NavigationLink, resize window size to smallest possible, go back to first NavigationLink toolbar buttons under >> buttons seems to be disabled and I need to resize window to fullsize to make them enabled again

Please share any ideas on this bug. Is it possible to fix this? Or maybe it's possible to implement what I need another way. I need to implement UI where sidebar contains multiple tabs so I can switch between them and open different Views for user

My code:

enum TabItems: String, CaseIterable, Identifiable {
case first
case second
case third

    var id: String {
        return rawValue
    }

}

struct ContentView: View {

    @State private var selection: TabItems? = TabItems.first
    
    var body: some View {
        NavigationView {
            List {
                ForEach(TabItems.allCases) { item in
                    NavigationLink(
                        destination: tabView(tab: item),
                        tag: item,
                        selection: $selection,
                        label: {
                            Text(item.id)}
                    )
                }
            }
        }
    }
    
    @ViewBuilder
    private func tabView(tab: TabItems) -> some View {
        switch tab {
        case .first:
            Text(tab.id)
                .toolbar {
                    ForEach(0 ..< 10) { _ in
                        Button(
                            action: {
                                print("button pressed")
                            },
                            label: {
                                Label(
                                    title: {
                                        Text("Button")
                                    },
                                    icon: {
                                        Image(systemName: "plus")
                                    }
                                )
                            }
                        )
                    }
                }
        case .second:
            Text(tab.id)
        case .third:
            Text(tab.id)
        }
    }

}

How to produce this bug:

  1. Run code
  2. Go to second Tab
  3. Resize window to smallest size
  4. Go back to first Tab
  5. Click on toolbar >> button to show hidden buttons

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.