Menu Tree selection closing a popup

I have a menu tree as a view I open as a popup. Opening works well but I'd like the menu selection to automatically close the popup. The closest I had was on item clicked event that closed the popup, but any click will close that of course. Trying to get it only when a submenu item is clicked.

Try using an event script on the view itself. Like this:

When a new screen opens, trigger the popup to close. You'll need to apply this to all your screens in the menu selection.

Thank you