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

Commit

Permalink
fix(menu): cleanup interim element on element destroy
Browse files Browse the repository at this point in the history
+ fixed typo
+ added test

Fixes #6545

  Closes #6558
  • Loading branch information
devversion authored and ThomasBurleson committed Jan 28, 2016
1 parent b3ffa6f commit 95fbb16
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/components/menu/js/menuController.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ function MenuController($mdMenu, $attrs, $element, $scope, $mdUtil, $timeout, $r
});

$scope.$on('$destroy', this.disableHoverListener);
menuContainer.on('$destroy', function() {
$mdMenu.destroy();
});
};

var openMenuTimeout, menuItems, deregisterScopeListeners = [];
Expand Down
2 changes: 1 addition & 1 deletion src/components/menu/js/menuServiceProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function MenuProvider($$interimElementProvider) {
}

/**
* Removing the menu element from the DOM and remove all associated evetn listeners
* Removing the menu element from the DOM and remove all associated event listeners
* and backdrop
*/
function onRemove(scope, element, opts) {
Expand Down
11 changes: 11 additions & 0 deletions src/components/menu/menu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ describe('material.components.menu', function() {
expect(clickDetected).toBe(false);
});

it('should remove the backdrop if container got destroyed', inject(function($document) {
var menu = setup();
openMenu(menu);

expect($document.find('md-backdrop').length).not.toBe(0);

menu.remove();

expect($document.find('md-backdrop').length).toBe(0);
}));

it('closes on backdrop click', inject(function($document) {

var menu = setup();
Expand Down

0 comments on commit 95fbb16

Please sign in to comment.