Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions goldens/cdk/overlay/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ export class OverlayContainer implements OnDestroy {

// @public
export interface OverlayDefaultConfig {
// (undocumented)
alwaysInline?: boolean;
// (undocumented)
usePopover?: boolean;
}
Expand Down
1 change: 1 addition & 0 deletions src/cdk/overlay/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {ScrollStrategyOptions} from './scroll/index';

/** Object used to configure the default options for overlays. */
export interface OverlayDefaultConfig {
alwaysInline?: boolean;
usePopover?: boolean;
}

Expand Down
6 changes: 6 additions & 0 deletions src/material/menu/menu-trigger-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
HorizontalConnectionPos,
OverlayConfig,
OverlayRef,
OVERLAY_DEFAULT_CONFIG,
ScrollStrategy,
VerticalConnectionPos,
} from '@angular/cdk/overlay';
Expand Down Expand Up @@ -354,19 +355,24 @@ export abstract class MatMenuTriggerBase implements OnDestroy {
* @returns OverlayConfig
*/
private _getOverlayConfig(menu: MatMenuPanel): OverlayConfig {
const inline =
this._injector.get(OVERLAY_DEFAULT_CONFIG, null, {optional: true})?.alwaysInline ?? false;

return new OverlayConfig({
positionStrategy: createFlexibleConnectedPositionStrategy(
this._injector,
this._getOverlayOrigin(),
)
.withLockedPosition()
.withGrowAfterOpen()
.withPopoverLocation(inline ? 'inline' : 'global')
.withTransformOriginOn('.mat-menu-panel, .mat-mdc-menu-panel'),
backdropClass: menu.backdropClass || 'cdk-overlay-transparent-backdrop',
panelClass: menu.overlayPanelClass,
scrollStrategy: this._scrollStrategy(),
direction: this._dir || 'ltr',
disableAnimations: this._animationsDisabled,
usePopover: true,
});
}

Expand Down
Loading