void () { // Called on AppKit when the menu closed myIsOpened = false; // When a user selects item of a system menu (under macOS), // AppKit sometimes generates such sequence: CloseParentMenu -> PerformItemAction // So we can destroy menu-item before item's action performed, and because of that action will not be executed. // Defer clearing to avoid this problem. disposeChildren(CLOSE_DELAY); // NOTE: don't clear native hierarchy here (see IDEA-315910) // It will be done when a menu opens next time. if (myOnClose != null) { invokeWithLWCToolkit(myOnClose, myComponent, false); } }