This could easily become a context menu utility function where you just pass a menu and a dom query string and it can handle the rest for any menu that opens under a button/element. So the same implementation could be used for the Recent Projects menu.