Mouse click detecting bug in PopupMenu

I also see issues with the recent changes: