title: SwiftUI: is it possible to use ForEach + ContextMenu + if statement?
body: <p>(tried on macOS only, but I believe there is the same behaviour on iOS)</p>
  
  <blockquote>
    <p>macOS 10.15.2 (19C57); Xcode: 11.3 (11C29)</p>
  </blockquote>
  
  <p>(question was updated because of I have found new relations in the issue)</p>
  
  <p>I have the following code:</p>
  
  <pre><code>List(model.filteredStatus) { status in
      StatusViewRow(status: status, model: self.model)
          .contextMenu{
              Text("menu 1")
              Text("menu 2")
          }
  }
  </code></pre>
  
  <p>It's works perfectly.</p>
  
  <p>But in case of I want to use ForEach instead ( no matter why):</p>
  
  <pre><code>ForEach(model.filteredStatus) { status in
      StatusViewRow(status: status, model: self.model)
          .contextMenu{
              Text("menu 1")
              Text("menu 2")
          }
  }
  </code></pre>
  
  <p>Context menu doesn't appear. </p>
  
  <p><strong>I have found the reason. Reason was in incorrect work of <code>ForEach</code> + <code>contextMenu</code> + <code>if</code> statement combination!</strong> </p>
  
  <p>ContextMenu doesn't work exactly on part of row inside of the <code>if</code> statement. Works well on the ful row with <code>List</code> and works only on the toogle row part when I'm using <code>ForEach</code>. </p>
  
  <p>Can somebody explain why so?</p>
  
  <p>I have an <code>if</code> statement inside of <code>StatusViewRow</code> contextMenu doesn't appear on this part:</p>
  
  <pre><code>struct StatusViewRow : View {
      @ObservedObject var status : FileStatusViewModel
      @ObservedObject var model : StatusViewModel
  
      var body: some View {
          HStack {
              TaoToggle(state: status.stageState) { self.status.toggleStageState() }
              // you can replace to just a toogle
  
  // ISSUE START HERE 
              if(model.fileNamesOnly) {
                  StyledText(verbatim: status.fileName )
                      .style(.highlight(), ranges: { [$0.lowercased().range(of: model.filterStr.lowercased() )]})
              } 
              else {
                  StyledText(verbatim: status.path )
                      .style(.foregroundColor(.gray), ranges: { [$0.range(of: status.fileDir) ] } )
                      .style(.bold(),                 ranges: { [$0.range(of: status.fileName) ] })
                      .style(.highlight(),            ranges: { [$0.lowercased().range(of: model.filterStr.lowercased() )]})
              }           
  // ISSUE END HERE
          }
      }
  }
  </code></pre>