`Invalid frame dimension (negative or non-finite)` on iPhone 12 mini

Hi everyone,

I’m encountering the following error when displaying a TextField inside a Form together with a ToolbarItem(placement: .keyboard):

Invalid frame dimension (negative or non-finite).

Environment

  • This issue reproduces on iPhone 12 mini (iOS 18.6).
  • The same code does not reproduce on iPhone 15.
  • I confirmed that explicitly constraining the size of the TextField or Text with .frame(width:height:) does not resolve the issue.

Minimal Reproducible Example

import SwiftUI

struct Test: View {
    @State var value: Int = 0

    var body: some View {
        Form {
            TextField("0", value: $value, format: .number)
        }
        .toolbar {
            ToolbarItem(placement: .keyboard) {
                Text("Close")
            }
        }
    }
}

Has anyone else encountered this issue? Is this a known bug, or is there a recommended workaround for devices with smaller screen widths such as the iPhone 12 mini?

Thanks in advance for your help!

Best regards,
Naoya Ozawa

`Invalid frame dimension (negative or non-finite)` on iPhone 12 mini
 
 
Q