Popovers icon indicating copy to clipboard operation
Popovers copied to clipboard

Possible retain cycle on UIKit menu?

Open Sega-Zero opened this issue 1 year ago • 4 comments

I noticed that if I present a menu, dismiss it and then present it again - the last menu item doesn't working. I tried to debug things and noticed that in Menu.swift the code:

 .onValueChange(of: model.selectedItemID) { _, newValue in

I get own itemID's that doesn't exist in the model. Like the old model of dismissed menu is still receiving this closure. Also, if I change onValueChanged to

.onChange(of: model.selectedItemID, do: { selectedID in
    if selectedID == itemID {
        action()
    }
    model.selectedItemID = nil
})

everything works correctly. I have a strong suspicion that ChangeObserver may have an unnecessary retain, but couldn't figure out that yet

Sega-Zero avatar Mar 18 '23 15:03 Sega-Zero