MCPcopy Create free account
hub / github.com/angular/components / MatMenu

Class MatMenu

src/material/menu/menu.ts:109–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107 providers: [{provide: MAT_MENU_PANEL, useExisting: MatMenu}],
108})
109export class MatMenu implements AfterContentInit, MatMenuPanel<MatMenuItem>, OnInit, OnDestroy {
110 private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
111 private _changeDetectorRef = inject(ChangeDetectorRef);
112 private _injector = inject(Injector);
113
114 private _keyManager!: FocusKeyManager<MatMenuItem>;
115 private _xPosition: MenuPositionX;
116 private _yPosition: MenuPositionY;
117 private _firstItemFocusRef?: AfterRenderRef;
118 private _exitFallbackTimeout: ReturnType<typeof setTimeout> | undefined;
119
120 /** Whether animations are currently disabled. */
121 protected _animationsDisabled = _animationsDisabled();
122
123 /** All items inside the menu. Includes items nested inside another menu. */
124 @ContentChildren(MatMenuItem, {descendants: true}) _allItems!: QueryList<MatMenuItem>;
125
126 /** Only the direct descendant menu items. */
127 _directDescendantItems = new QueryList<MatMenuItem>();
128
129 /** Classes to be applied to the menu panel. */
130 _classList: {[key: string]: boolean} = {};
131
132 /** Current state of the panel animation. */
133 _panelAnimationState: 'void' | 'enter' = 'void';
134
135 /** Emits whenever an animation on the menu completes. */
136 readonly _animationDone = new Subject<'void' | 'enter'>();
137
138 /** Whether the menu is animating. */
139 _isAnimating = signal(false);
140
141 /** Parent menu of the current menu panel. */
142 parentMenu: MatMenuPanel | undefined;
143
144 /** Layout direction of the menu. */
145 direction!: Direction;
146
147 /** Class or list of classes to be added to the overlay panel. */
148 overlayPanelClass: string | string[];
149
150 /** Class to be added to the backdrop element. */
151 @Input() backdropClass: string;
152
153 /** aria-label for the menu panel. */
154 @Input('aria-label') ariaLabel!: string;
155
156 /** aria-labelledby for the menu panel. */
157 @Input('aria-labelledby') ariaLabelledby!: string;
158
159 /** aria-describedby for the menu panel. */
160 @Input('aria-describedby') ariaDescribedby!: string;
161
162 /** Position of the menu in the X axis. */
163 @Input()
164 get xPosition(): MenuPositionX {
165 return this._xPosition;
166 }

Callers

nothing calls this directly

Calls 3

_animationsDisabledFunction · 0.90
signalFunction · 0.85
getIdMethod · 0.45

Tested by

no test coverage detected