Skip to content

Commit d090d8e

Browse files
committed
fix(material/menu): allow conditional inlining of menu popover
1 parent 744c396 commit d090d8e

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

goldens/cdk/overlay/index.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ export class OverlayContainer implements OnDestroy {
439439

440440
// @public
441441
export interface OverlayDefaultConfig {
442+
// (undocumented)
443+
alwaysInline?: boolean;
442444
// (undocumented)
443445
usePopover?: boolean;
444446
}

src/cdk/overlay/overlay.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {ScrollStrategyOptions} from './scroll/index';
3434

3535
/** Object used to configure the default options for overlays. */
3636
export interface OverlayDefaultConfig {
37+
alwaysInline?: boolean;
3738
usePopover?: boolean;
3839
}
3940

src/material/menu/menu-trigger-base.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
HorizontalConnectionPos,
1818
OverlayConfig,
1919
OverlayRef,
20+
OVERLAY_DEFAULT_CONFIG,
2021
ScrollStrategy,
2122
VerticalConnectionPos,
2223
} from '@angular/cdk/overlay';
@@ -354,19 +355,24 @@ export abstract class MatMenuTriggerBase implements OnDestroy {
354355
* @returns OverlayConfig
355356
*/
356357
private _getOverlayConfig(menu: MatMenuPanel): OverlayConfig {
358+
const inline =
359+
this._injector.get(OVERLAY_DEFAULT_CONFIG, null, {optional: true})?.alwaysInline ?? false;
360+
357361
return new OverlayConfig({
358362
positionStrategy: createFlexibleConnectedPositionStrategy(
359363
this._injector,
360364
this._getOverlayOrigin(),
361365
)
362366
.withLockedPosition()
363367
.withGrowAfterOpen()
368+
.withPopoverLocation(inline ? 'inline' : 'global')
364369
.withTransformOriginOn('.mat-menu-panel, .mat-mdc-menu-panel'),
365370
backdropClass: menu.backdropClass || 'cdk-overlay-transparent-backdrop',
366371
panelClass: menu.overlayPanelClass,
367372
scrollStrategy: this._scrollStrategy(),
368373
direction: this._dir || 'ltr',
369374
disableAnimations: this._animationsDisabled,
375+
usePopover: true,
370376
});
371377
}
372378

0 commit comments

Comments
 (0)