MCPcopy Index your code
hub / github.com/angular/components / _subscribeToOutsideClicks

Method _subscribeToOutsideClicks

src/cdk/menu/menu-trigger.ts:325–343  ·  view source on GitHub ↗

* Subscribe to the overlays outside pointer events stream and handle closing out the stack if a * click occurs outside the menus.

()

Source from the content-addressed store, hash-verified

323 * click occurs outside the menus.
324 */
325 private _subscribeToOutsideClicks() {
326 if (this.overlayRef) {
327 this.overlayRef
328 .outsidePointerEvents()
329 .pipe(takeUntil(this.stopOutsideClicksListener))
330 .subscribe(event => {
331 const target = _getEventTarget(event) as Element;
332 const element = this._elementRef.nativeElement;
333
334 if (target !== element && !element.contains(target)) {
335 if (!this.isElementInsideMenuStack(target)) {
336 this.menuStack.closeAll();
337 } else {
338 this._closeSiblingTriggers();
339 }
340 }
341 });
342 }
343 }
344
345 /** Subscribe to the MenuStack hasFocus events. */
346 private _subscribeToMenuStackHasFocus() {

Callers 1

openMethod · 0.95

Calls 4

_closeSiblingTriggersMethod · 0.95
_getEventTargetFunction · 0.90
outsidePointerEventsMethod · 0.80
closeAllMethod · 0.45

Tested by

no test coverage detected