title: SwiftUI: Incorrect UI when switching to a new list from an old one with swipe button shown
body: <p>The issue can be reproduced consistently with the code below. Xcode 13.3 + iOS 15.4 (both are latest).</p>
  <pre><code>enum ListID: String, CaseIterable, Hashable, Identifiable {
      case list1 = &quot;List1&quot;
      case list2 = &quot;List2&quot;
      
      var id: Self {
          self
      }
  }
  
  struct ContentView: View {
      @State var listID: ListID = .list1
      
      var body: some View {
          VStack {
              // 1) Picker
              Picker(selection: $listID) {
                  ForEach(ListID.allCases) { id in
                      Text(id.rawValue)
                  }
              } label: {
                  Text(&quot;Select a list&quot;)
              }
              .pickerStyle(.segmented)
              // 2) List
              switch listID {
              case .list1:
                  createList(Array(1...2), id: .list1)
              case .list2:
                  createList(Array(101...102), id: .list2)
              }
          }
  
      }
      
      @ViewBuilder func createList(_ itemValues: [Int], id: ListID) -&gt; some View {
          List {
              ForEach(itemValues, id:\.self) { value in
                  Text(&quot;\(value)&quot;)
                      .swipeActions(edge: .trailing, allowsFullSwipe: false) {
                          Button(&quot;Edit&quot;) {
                              // do nothing
                          }
                          .tint(.blue)
                      }
              }
          }
          .id(id)
      }
  }
  </code></pre>
  <p>Steps to reproduce the issue:</p>
  <ol>
  <li>start up the app. See picture 1.</li>
  <li>swipe item 1 in list 1, keep the &quot;Edit&quot; button untouched (don't click on it). See picture 2</li>
  <li>then select list 2 in the picker. You should see there is an extra space before the items in the list. What's more, all list items are not swipable any more. See picture 3.</li>
  <li>then select list 1 in the picker. It has the same issue. See picture 4.</li>
  </ol>
  <p><a href="https://i.stack.imgur.com/IVpU2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IVpU2.png" alt="step 1" /></a>
  <a href="https://i.stack.imgur.com/yHi8x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yHi8x.png" alt="step 2" /></a>
  <a href="https://i.stack.imgur.com/enWBp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/enWBp.png" alt="step 3" /></a>
  <a href="https://i.stack.imgur.com/2GBFq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2GBFq.png" alt="step 4" /></a></p>
  <p>The issue is not specific to picker. For example, it can be reproduced if we replace picker with a set of buttons. I believe the issue occurs only if the old list is destroyed in SwiftUI view hierarchy. From my understanding of structured identity in SwiftUI, list 1 and list 2 are considered separate views in SwiftUI view hiearch. So it's not clear how they could affect each other. The only reason I can guess is that, while list 1 and list 2 are considered separate virtual views, SwiftUI actually use the same physical view for them (e.g., for performance purpose, etc.). So it seems a SwiftUI bug to me.</p>
  <p>Thinking along that line, I can work round the issue by not destroying lists:</p>
  <pre><code>ZStack {
      createList(Array(1...2), id: .list1)
          .opacity(listID == .list1 ? 1 : 0)
      createList(Array(101...102), id: .list2)
          .opacity(listID == .list2 ? 1 : 0)
  }
  </code></pre>
  <p>This works perfectly in this specific example, but unfortunately it's not scalable. For example, in my calendar app when user clicks on a date in the calendar, I'd like to show a list of events on the date (I'd like to use different list for different date. I do so by calling <code>id()</code> to set different id to each list). There isn't an obvious/elegant way to apply the above work around in this case.</p>
  <p>So I wonder if anyone knows how to work around the issue in a more general way? Thanks.</p>