Found a workaround:
struct DetailsView: View {
@Environment(\.dismiss) private var dismiss
@Binding var selectedFolder: Folder?
@Environment(\.scenePhase) private var scenePhase
@State var refreshID = UUID()
var body: some View {
VStack {
if let folder = selectedFolder {
Text(folder.name)
}
else {
Text("No selection")
}
}
.onChange(of: scenePhase) { _, newPhase in
refreshID = UUID()
}
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button {
dismiss()
} label: {
Text("Cancel")
}
.id(refreshID)
}
ToolbarItem(placement: .confirmationAction) {
Button {
dismiss()
} label: {
Text("Save")
}
.id(refreshID)
}
}
}
}
Forcing an ID refresh seems to work but still, this should be fixed.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: