I would use ng-bootstrap if you hadnโt already, and in particular the NgbDropdown component.
https://ng-bootstrap.imtqy.com/#/components/dropdown
It has an openChange event that fires when a menu opens or closes, and you can listen to this event and fire your own logic.
It also has an isOpen method, which you can check to open whether the menu is open or not.
If these options do not perform the trick, you can turn off the drop-down menu button and create your own button to switch the drop-down menu and use manual triggers to open the menu and start your user logic and stop your logic and close the menu, although be careful to make the elementary the interface looked strange, as it confused users.
source share