Double sheet can not be dismissed

There is a constructure using double sheet in my app, which open a sheet to edit a item(depth 1), and it can open another sheet to edit the field in the item (depth 2). In my case, I have encountered a bug that if I go down to the second sheet(depth 2), and then I dismiss the second sheet(depth 2), then I can't dismiss the first sheet(depth 1)

here is the sample code, I test it in Xcode 14.1 RC2 and ios16.1 on both simulator and physical devices.


import SwiftUI
import CoreData

struct ContentView: View {
    @State private var isSubPresented = false
    @Environment(\.dismiss) var dismiss
    var body: some View {
        Text("Main")
            .sheet(isPresented: $isSubPresented) {
                VStack {
                    SubView()
                    
                    Button("dismiss") {
//                        dismiss() // not work at all
                        isSubPresented = false
                    }
                    .padding()
                }
            }
            .onTapGesture {
                self.isSubPresented = true
            }
    }
}

struct SubView: View {
    
    @State private var isPresented: Bool = false
    @Environment(\.dismiss) var dismiss
    var body: some View {
        Button("into Sub edit") {
            self.isPresented = true
        }
            .sheet(isPresented: $isPresented) {
                Form {
                    
                    Button("dismiss") {
                        dismiss()
                    }
                }
            }
    }
}


struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)
    }
}

Double sheet also causes the Chinese input method with 10-key keyboard (九宫格) cannot to work normally, once the typed characters are changed due to the mechanism of input prediction, the pending status of the inputted character will go away, which means totally not useable :(

Double sheet can not be dismissed
 
 
Q