Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 1a9a530

Browse files
isyunThomasBurleson
authored andcommitted
fix(menu): fix memory leak on component destroy
Closes #3775.
1 parent 2132cd2 commit 1a9a530

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/menu/_menu.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,8 @@ function MenuDirective($mdMenu) {
167167
mdMenuCtrl.init(menuContainer);
168168

169169
scope.$on('$destroy', function() {
170-
if (mdMenuCtrl.isOpen) {
171-
menuContainer.remove();
172-
mdMenuCtrl.close();
173-
}
170+
menuContainer.remove();
171+
mdMenuCtrl.close();
174172
});
175173

176174
}
@@ -207,6 +205,8 @@ function MenuController($mdMenu, $attrs, $element, $scope) {
207205

208206
// Use the $mdMenu interim element service to close the menu contents
209207
this.close = function closeMenu(skipFocus) {
208+
if ( !ctrl.isOpen ) return;
209+
210210
ctrl.isOpen = false;
211211
triggerElement.setAttribute('aria-expanded', 'false');
212212
$mdMenu.hide();

0 commit comments

Comments
 (0)