File tree 2 files changed +27
-2
lines changed 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -195,7 +195,9 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
195
195
return ;
196
196
}
197
197
198
- this . _createOverlay ( ) . attach ( this . _portal ) ;
198
+ const overlayRef = this . _createOverlay ( ) ;
199
+ overlayRef . setDirection ( this . dir ) ;
200
+ overlayRef . attach ( this . _portal ) ;
199
201
200
202
if ( this . menu . lazyContent ) {
201
203
this . menu . lazyContent . attach ( this . menuData ) ;
@@ -344,7 +346,6 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
344
346
positionStrategy : this . _getPosition ( ) ,
345
347
hasBackdrop : this . menu . hasBackdrop == null ? ! this . triggersSubmenu ( ) : this . menu . hasBackdrop ,
346
348
backdropClass : this . menu . backdropClass || 'cdk-overlay-transparent-backdrop' ,
347
- direction : this . dir ,
348
349
scrollStrategy : this . _scrollStrategy ( )
349
350
} ) ;
350
351
}
Original file line number Diff line number Diff line change @@ -245,6 +245,30 @@ describe('MatMenu', () => {
245
245
expect ( overlayPane . getAttribute ( 'dir' ) ) . toEqual ( 'rtl' ) ;
246
246
} ) ;
247
247
248
+ it ( 'should update the panel direction if the trigger direction changes' , ( ) => {
249
+ const dirProvider = { value : 'rtl' } ;
250
+ const fixture = createComponent ( SimpleMenu , [ {
251
+ provide : Directionality , useFactory : ( ) => dirProvider }
252
+ ] , [ FakeIcon ] ) ;
253
+
254
+ fixture . detectChanges ( ) ;
255
+ fixture . componentInstance . trigger . openMenu ( ) ;
256
+ fixture . detectChanges ( ) ;
257
+
258
+ let overlayPane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) ! ;
259
+ expect ( overlayPane . getAttribute ( 'dir' ) ) . toEqual ( 'rtl' ) ;
260
+
261
+ fixture . componentInstance . trigger . closeMenu ( ) ;
262
+ fixture . detectChanges ( ) ;
263
+
264
+ dirProvider . value = 'ltr' ;
265
+ fixture . componentInstance . trigger . openMenu ( ) ;
266
+ fixture . detectChanges ( ) ;
267
+
268
+ overlayPane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) ! ;
269
+ expect ( overlayPane . getAttribute ( 'dir' ) ) . toEqual ( 'ltr' ) ;
270
+ } ) ;
271
+
248
272
it ( 'should transfer any custom classes from the host to the overlay' , ( ) => {
249
273
const fixture = createComponent ( SimpleMenu , [ ] , [ FakeIcon ] ) ;
250
274
You can’t perform that action at this time.
0 commit comments