File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -291,6 +291,15 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy {
291
291
}
292
292
}
293
293
294
+ /**
295
+ * Updates the position of the menu to ensure that it fits all options within the viewport.
296
+ */
297
+ updatePosition ( ) : void {
298
+ if ( this . _overlayRef ) {
299
+ this . _overlayRef . updatePosition ( ) ;
300
+ }
301
+ }
302
+
294
303
/** Closes the menu and does the necessary cleanup. */
295
304
private _destroyMenu ( reason : MenuCloseReason ) {
296
305
if ( ! this . _overlayRef || ! this . menuOpen ) {
Original file line number Diff line number Diff line change @@ -1280,6 +1280,10 @@ describe('MatMenu', () => {
1280
1280
. toBe ( Math . floor ( trigger . getBoundingClientRect ( ) . bottom ) , 'Expected menu to open below' ) ;
1281
1281
} ) ;
1282
1282
1283
+ it ( 'should not throw if a menu reposition is requested while the menu is closed' , ( ) => {
1284
+ expect ( fixture . componentInstance . trigger . updatePosition ( ) ) . not . toThrow ( ) ;
1285
+ } ) ;
1286
+
1283
1287
} ) ;
1284
1288
1285
1289
describe ( 'fallback positions' , ( ) => {
You can’t perform that action at this time.
0 commit comments