7

When I embed my view's body inside of a NavigationView I lose all ability to select subviews within the preview window, as well as the reverse ability of selecting code to trigger and display the blue border around the associated subview in the preview. It only shows a blue border around the entire NavigationView no matter what or where I click. Is this a bug? If not, what am I doing wrong?

Edit: Per the request of the comments below, here is a simple example:

struct FooView: View {

    var body: some View {
        NavigationView {
            VStack {
                Label("Try")
                Label("Selecting")
                Label("These")
            }
        }
    }
}
Aaron
  • 6,466
  • 7
  • 37
  • 75
  • Without a [Minimal Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) it is impossible to help you troubleshoot. – lorem ipsum Jun 21 '21 at 23:14
  • Probably a bug or "feature"... – aheze Jun 21 '21 at 23:21
  • The example is embedding literally anything in a `NavigationView` and trying to select it. – Aaron Jun 21 '21 at 23:23
  • show us the code you are having these issues with, so we can have a look and help you. – workingdog support Ukraine Jun 22 '21 at 00:51
  • Alright, example added. – Aaron Jun 22 '21 at 04:23
  • I think you should wrapper your text with ```VStack{``` or ```HStack{``` from any view container. – Raja Kishan Jun 22 '21 at 08:35
  • That is because with this setup you are presenting a [stack of Views](https://developer.apple.com/documentation/swiftui/navigationview) the `Text` is the whole screen/column. They aren't rows as would be assumed. – lorem ipsum Jun 22 '21 at 12:47
  • 1
    Ok, my point is that if you put anything in a `NavigationStack`, whether it's HStack, VStack, a container of buttons, labels, etc. you cannot highlight them in the preview or vice versa. I've updated the example. – Aaron Jun 22 '21 at 16:51
  • 1
    Almost a year later and I am seeing this issue with Xcode 14.0 beta as well. – dejo Jun 16 '22 at 19:21

0 Answers0