Using TextField in an .alert() and this bug seems to be preventing the OK button from executing:
.alert("New Category", isPresented: $showNewCategoryNameAlert) {
TextField("Enter Name", text: $userNewCategoryName)
Button("OK", action: {
print("Clicked OK")
addCategory(newName: userNewCategoryName)
userNewCategoryName = ""
}).disabled(userNewCategoryName.isEmpty)
Button("Cancel", role: .cancel) { }
Enter Name
Tap OK - dismisses
Print statement and addCategory don't run
BUT! Launch the .alert() again and click OK, everything executes. This issue is not present in iOS 18. Open to ideas for a work around!
Topic:
UI Frameworks
SubTopic:
General
Tags: