Can TextField handle undo?

I'm struggling to understand whether TextField handles undo by itself, or how to properly handle it myself.

In a macOS app with a SwiftUI lifecycle, in a DocumentGroup scene, I'm using both TextEditors and Textfields. The text editors handle undo out of the box, with undo coalescing.

The text fields seem not to. However, on occasion, they do create undo points, leaving me confused as to what conditions are needed for that to happen.

Is there a way to reliably get text fields to handle undo on their own? Or, how should I implement typing undo, including undo coalescing, manually?

In MacOS with AppKit, you get it directly in the storyboard, by activating the undo checkbox.

Hope that helps.

Thanks for the tip! I am using SwiftUI, however, so its's the SwiftUI TextEditor and TextField views that I'm trying to understand.

Can TextField handle undo?
 
 
Q