SwiftUI Picker inside Menu does not initially show checkmark for selected option

Viewed 514

I am trying to implement a Picker embedded inside a Menu in SwiftUI, following this post. However, there seems to be a bug where the picker does not initially show a checkmark next to the currently selected option when embedded inside a Menu.

Menu {
    Picker("Unit", selection: $food.servingSize.unit) {
        ForEach(units) { unit in
            Text(unit.name).tag(unit)
        }
    }
} label: {
    Text(food.servingSize.unit.shorthand)
}

enter image description here

However, if I don't use Menu and just the Picker by itself instead, the default selection works as expected:

Picker("Unit", selection: $food.servingSize.unit) {
    ForEach(units) { unit in
        Text(unit.name).tag(unit)
    }
}
.pickerStyle(.menu)

enter image description here

Obviously I want to use the Menu in order to change what is being displayed after selection from the Picker. What am I missing here?

0 Answers
Related