Always re-create SwiftUI Window without previous data

Hey everyone! I'm taking a look at all the new APIs and I'd really love to implement some forms in my app in a new window instead of in a sheet as I'm currently making them. Basically I have a couple of forms that gather data from the user and add new stuff to the database. I initially did this by using the new Window API and dismissing it via the dismiss action in the environment once the user clicks "Add", but when I try to create a new Window it seems like the view keeps its state and doesn't really gets re-created, which means that all the forms contain the previous values that I don't need anymore.

Is there any nice way to achieve this? I think that I can make this work by making it a WindowGroup and using the openWindow function that accepts a value and passing a new UUID every time, but I don't think this is a good idea since as mentioned on the talk these values get persisted.

Bug?

I don’t think it’s a but, it’s mentioned specifically in the session that this is desired behavior. Just not sure if there’s a way to override it :)

Always re-create SwiftUI Window without previous data
 
 
Q