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

Commit d208ac5

Browse files
crisbetokara
authored andcommitted
fix(panel): element not being removed when scope is destroyed (#9567)
The panel element wasn't being removed when it's scope is destroyed (e.g. when navigating to a different page). Fixes #8683.
1 parent 0ce8a57 commit d208ac5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/components/panel/panel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ MdPanelService.prototype.create = function(config) {
817817

818818
var panelRef = new MdPanelRef(this._config, this._$injector);
819819
this._trackedPanels[config.id] = panelRef;
820+
this._config.scope.$on('$destroy', angular.bind(panelRef, panelRef.detach));
820821

821822
return panelRef;
822823
};

src/components/panel/panel.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ describe('$mdPanel', function() {
114114
expect(PANEL_EL).not.toExist();
115115
});
116116

117+
it('should remove a panel from the DOM when the scope is destroyed', function() {
118+
openPanel();
119+
120+
expect(PANEL_EL).toExist();
121+
122+
panelRef.config.scope.$destroy();
123+
124+
expect(PANEL_EL).not.toExist();
125+
});
126+
117127
it('should hide and show a panel in the DOM', function() {
118128
openPanel(DEFAULT_CONFIG);
119129

0 commit comments

Comments
 (0)