I could not test on iOS 17 (my sample project crashes Xcode 15.3). Do you confirm it works there ?
I see the same on iOS 18:
DetailView initialized
DetailView appeared
DetailView task executed
-->> button tapped
DetailView disappeared
DetailView appeared
DetailView disappeared
DetailView task executed
This discussion may be interesting to read, even it did not let me understand what happens: https://fatbobman.com/en/posts/mastering_swiftui_task_modifier/
Topic:
UI Frameworks
SubTopic:
SwiftUI