SwiftUI textfield inside sheet produces extra padding when keyboard shown

I want to present a textfield inside a sheet.

However when the keyboard is shown, the sheet view produces extra padding even though I explicitly set the frame of the textfield and the presentationDent to be the exact same height.

Reproducible example:

struct ContentView: View {
    @State var showSheet: Bool = false
    @State var text = ""
    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.tint)
            Text("Hello, world!")
            
            Button {
                showSheet.toggle()
            } label: {
                Text("Show Sheet")
            }
            
        }
        .sheet(isPresented: $showSheet) {
            TextField("Hello", text: $text)
                .frame(height: 44)
                .background(.red)
                .presentationDetents([.height(44)])
                .presentationDragIndicator(.hidden)
        }
    }
}

Does anyone know how to resolve this issue?

Thanks for the post and apologies for the delay.

Do you get the same results with just the relevant code in a small test project? If so, please share a link to your test project. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project.

Albert Pascual
  Worldwide Developer Relations.

SwiftUI textfield inside sheet produces extra padding when keyboard shown
 
 
Q