I have a simple List inside a NavigationView with a toolbar that contains a Picker. When I select an option in the picker, the variable value changes, but when I click again on the picker it shows the default variable value.
This does not seems to happen when I put the picker on another container, for example directly in the List, so it seems to be a problem with the toolbar itself.
Here is my code:
struct ExampleView: View {
//this is a enum that conforms Equatable, Hashable, CaseIterable
@State private var sort: MediaListSort = .updatedTimeDesc
var body: some View {
List {
//...
}
.toolbar {
ToolbarItem {
Picker("Sort", selection: $sort) {
Text("Title").tag(MediaListSort.mediaTitleNativeDesc)
Text("Score").tag(MediaListSort.scoreDesc)
Text("Last Updated").tag(MediaListSort.updatedTimeDesc)
Text("Last Added").tag(MediaListSort.addedTimeDesc)
}
}
}
}
}
Behaviour:
I am currently using the latest Xcode 14 beta 04, so I am not sure if this issue is related to that.