On a SecureField in SwiftUI How do you remove the password fill box on OSX?

Viewed 135

enter image description here

I cannot figure out how to remove this Passwords autofill box in SwiftUI when building for macOS. I have tried different kinds of textContentType but nothing gets rid of this box. It is blocking my attempt to login to my app from a return press. Both the onCommit, or the keyboardShortcut modifier return press is being swallowed by this box. The strange thing is, I create a blank new app with one SecureField, and the box is not there. I am wondering if there is some kind of initial setup telling the app to use suggested passwords? I know in the past our team looked at password autofill and supporting Associated Domains.

1 Answers

I managed to prevent the "Passwords…" box from appearing on my app by making two things:

  1. Passing .username to the .textContentType(_:) modifier of the email TextField.
  2. Passing nil to the .textContentType(_:) modifier of the password SecureField.

I tested this solution on macOS 12.4 and Xcode 13.4.1 (13F100).

Related