@henrik273 thanks for confirming this is a SwiftUI bug - it's been driving me nuts for days.
It seems the button uses the initial disabled state upon tapping it, regardless of its current disabled state.
This is the only reliable work-around I've found:
set the initial state to be .disabled(isDisabled) where isDisabled is false.
set the text field to have some default text that the user must delete.
when the user deletes all the text, isDisabled becomes true.
The closure only gets called if the initial state is .disabled(false) rather than .disabled(true). Also, the alert must appear with .disabled(false) before you update to .disabled(true).
Another hack could be to use DispatchQueue to update .disabled(true) ~0.6 seconds later (so after the alert appears), but I wouldn't recommend this as it's not reliable.
I hope this helps whilst the bug is fixed.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: