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

Commit

Permalink
fix(mdMenu): close on scope $destroy
Browse files Browse the repository at this point in the history
closes #3189
  • Loading branch information
rschmukler committed Jun 11, 2015
1 parent 94b03b0 commit 67be5ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/components/menu/_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ function MenuDirective($mdMenu) {
menuContainer.append(menuContents);
mdMenuCtrl.init(menuContainer);

scope.$on('$destroy', function() {
if (mdMenuCtrl.isOpen) {
menuContainer.remove();
mdMenuCtrl.close();
}
});

}
}

Expand All @@ -178,6 +185,7 @@ function MenuController($mdMenu, $attrs, $element, $scope) {

// Uses the $mdMenu interim element service to open the menu contents
this.open = function openMenu() {
ctrl.isOpen = true;
$element.attr('aria-expanded', 'true');
$mdMenu.show({
mdMenuCtrl: ctrl,
Expand All @@ -190,6 +198,7 @@ function MenuController($mdMenu, $attrs, $element, $scope) {

// Use the $mdMenu interim element service to close the menu contents
this.close = function closeMenu(skipFocus) {
ctrl.isOpen = false;
$element.attr('aria-expanded', 'false');
$mdMenu.hide();

Expand Down
1 change: 0 additions & 1 deletion src/components/menu/menu-interim-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ function MenuProvider($$interimElementProvider) {
* @param {object} opts - the interim element options object
*/
function positionMenu(el, opts) {
debugger;
if (opts.isRemoved) return;

var containerNode = el[0],
Expand Down

0 comments on commit 67be5ce

Please sign in to comment.