domino-ui
domino-ui copied to clipboard
Menu close handler not always called
It appears that when you add a close handler to a menu, it's not always called.
From what I can tell, when the shown menu has the close() method called directly, it works just fine. However, when the menu is getting closed through clicking elsewhere on the screen, the handler is not called.
Tracing through, it appears that the PopupsCloser.close()
method is just iterating across all elements with the closeable selector and removing from DOM (via element.remove()
). That DOES trigger the body observer that the menu has and the close()
method is called; however isOpened()
returns false because the element is no longer attached; thus not allowing it to iterate the close handler and call them properly.
places in code for reference: PopupsCloser.close(selector): https://github.com/DominoKit/domino-ui/blob/master/domino-ui/src/main/java/org/dominokit/domino/ui/utils/PopupsCloser.java#L54
AbstractMenu.close(): https://github.com/DominoKit/domino-ui/blob/master/domino-ui/src/main/java/org/dominokit/domino/ui/menu/AbstractMenu.java#L896
AbstractMenu.isOpened() : https://github.com/DominoKit/domino-ui/blob/master/domino-ui/src/main/java/org/dominokit/domino/ui/menu/AbstractMenu.java#L757