MCPcopy
hub / github.com/angular/components / _open

Method _open

src/cdk/menu/context-menu-trigger.ts:210–238  ·  view source on GitHub ↗

* Open the attached menu at the specified location. * @param userEvent User-generated event that opened the menu * @param coordinates where to open the context menu

(userEvent: MouseEvent | null, coordinates: ContextMenuCoordinates)

Source from the content-addressed store, hash-verified

208 * @param coordinates where to open the context menu
209 */
210 private _open(userEvent: MouseEvent | null, coordinates: ContextMenuCoordinates) {
211 if (this.disabled) {
212 return;
213 }
214 if (this.isOpen()) {
215 // since we're moving this menu we need to close any submenus first otherwise they end up
216 // disconnected from this one.
217 this.menuStack.closeSubMenuOf(this.childMenu!);
218
219 (
220 this.overlayRef!.getConfig().positionStrategy as FlexibleConnectedPositionStrategy
221 ).setOrigin(coordinates);
222 this.overlayRef!.updatePosition();
223 } else {
224 this.opened.next();
225
226 if (this.overlayRef) {
227 (
228 this.overlayRef.getConfig().positionStrategy as FlexibleConnectedPositionStrategy
229 ).setOrigin(coordinates);
230 this.overlayRef.updatePosition();
231 } else {
232 this.overlayRef = createOverlayRef(this._injector, this._getOverlayConfig(coordinates));
233 }
234
235 this.overlayRef.attach(this.getMenuContentPortal());
236 this._subscribeToOutsideClicks(userEvent);
237 }
238 }
239}

Callers 2

openMethod · 0.95
_openOnContextMenuMethod · 0.95

Calls 10

_getOverlayConfigMethod · 0.95
createOverlayRefFunction · 0.90
closeSubMenuOfMethod · 0.80
setOriginMethod · 0.80
getConfigMethod · 0.80
attachMethod · 0.65
isOpenMethod · 0.45
updatePositionMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected