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

Commit 78b1073

Browse files
atfzlsSplaktar
authored andcommitted
feat(menu): render backdrop to backdropParent
- attach the backdrop in menu to `options.backdropParent`
1 parent 4d75a8c commit 78b1073

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/components/menu/js/menuServiceProvider.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function MenuProvider($$interimElementProvider) {
5959
if (options.hasBackdrop) {
6060
options.backdrop = $mdUtil.createBackdrop(scope, "md-menu-backdrop md-click-catcher");
6161

62-
$animate.enter(options.backdrop, $document[0].body);
62+
$animate.enter(options.backdrop, options.backdropParent || $document[0].body);
6363
}
6464

6565
/**

src/components/menu/menu.spec.js

+28
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,34 @@ describe('material.components.menu', function() {
397397
$log = $injector.get('$log');
398398
}));
399399

400+
it('backdrop should attach to backdropParent', function() {
401+
var parent = angular.element('<div>');
402+
var menuEl = angular.element(
403+
'<md-menu>' +
404+
' <button ng-click="null">Trigger</button>' +
405+
'</md-menu>'
406+
);
407+
var backdropParent = angular.element('<div>');
408+
409+
$mdMenu.show({
410+
scope: $rootScope,
411+
element: menuEl,
412+
target: document.body,
413+
preserveElement: true,
414+
parent: parent,
415+
backdropParent: backdropParent,
416+
});
417+
418+
$timeout.flush();
419+
420+
expect(backdropParent.find('md-backdrop').length).toBe(1);
421+
422+
// Close the menu and remove the containers
423+
$mdMenu.hide();
424+
parent.remove();
425+
backdropParent.remove();
426+
});
427+
400428
it('should warn when the md-menu-content element is missing', function() {
401429
spyOn($log, 'warn');
402430

0 commit comments

Comments
 (0)