This repository was archived by the owner on Sep 5, 2024. It is now read-only.
File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ function MenuProvider($$interimElementProvider) {
59
59
if ( options . hasBackdrop ) {
60
60
options . backdrop = $mdUtil . createBackdrop ( scope , "md-menu-backdrop md-click-catcher" ) ;
61
61
62
- $animate . enter ( options . backdrop , $document [ 0 ] . body ) ;
62
+ $animate . enter ( options . backdrop , options . backdropParent || $document [ 0 ] . body ) ;
63
63
}
64
64
65
65
/**
Original file line number Diff line number Diff line change @@ -397,6 +397,34 @@ describe('material.components.menu', function() {
397
397
$log = $injector . get ( '$log' ) ;
398
398
} ) ) ;
399
399
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
+
400
428
it ( 'should warn when the md-menu-content element is missing' , function ( ) {
401
429
spyOn ( $log , 'warn' ) ;
402
430
You can’t perform that action at this time.
0 commit comments