|
8 | 8 |
|
9 | 9 | import {
|
10 | 10 | Directive,
|
11 |
| - Input, |
12 |
| - ViewContainerRef, |
13 |
| - Output, |
14 | 11 | EventEmitter,
|
15 |
| - Optional, |
16 |
| - OnDestroy, |
17 | 12 | Inject,
|
18 | 13 | Injectable,
|
19 | 14 | InjectionToken,
|
| 15 | + Input, |
| 16 | + OnDestroy, |
| 17 | + Optional, |
| 18 | + Output, |
| 19 | + ViewContainerRef, |
20 | 20 | } from '@angular/core';
|
21 | 21 | import {Directionality} from '@angular/cdk/bidi';
|
22 | 22 | import {
|
23 |
| - OverlayRef, |
| 23 | + ConnectedPosition, |
| 24 | + FlexibleConnectedPositionStrategy, |
24 | 25 | Overlay,
|
25 | 26 | OverlayConfig,
|
26 |
| - FlexibleConnectedPositionStrategy, |
27 |
| - ConnectedPosition, |
| 27 | + OverlayRef, |
28 | 28 | } from '@angular/cdk/overlay';
|
29 |
| -import {TemplatePortal, Portal} from '@angular/cdk/portal'; |
30 |
| -import {coerceBooleanProperty, BooleanInput} from '@angular/cdk/coercion'; |
31 |
| -import {Subject, merge} from 'rxjs'; |
32 |
| -import {takeUntil} from 'rxjs/operators'; |
| 29 | +import {Portal, TemplatePortal} from '@angular/cdk/portal'; |
| 30 | +import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; |
| 31 | +import {merge, partition, Subject} from 'rxjs'; |
| 32 | +import {skip, takeUntil} from 'rxjs/operators'; |
33 | 33 | import {CdkMenuPanel} from './menu-panel';
|
34 | 34 | import {MenuStack} from './menu-stack';
|
35 | 35 | import {throwExistingMenuStackError} from './menu-errors';
|
@@ -287,8 +287,11 @@ export class CdkContextMenuTrigger implements OnDestroy {
|
287 | 287 | */
|
288 | 288 | private _subscribeToOutsideClicks() {
|
289 | 289 | if (this._overlayRef) {
|
290 |
| - this._overlayRef |
291 |
| - .outsidePointerEvents() |
| 290 | + const allClicks = this._overlayRef.outsidePointerEvents(); |
| 291 | + const [auxClicks, nonAuxClicks] = partition(allClicks, ({type}) => type === 'auxclick'); |
| 292 | + // Skip the first auxclick event because it fires on mouseup after the |
| 293 | + // contextmenu event that opened the menu. |
| 294 | + merge(nonAuxClicks, auxClicks.pipe(skip(1))) |
292 | 295 | .pipe(takeUntil(this._stopOutsideClicksListener))
|
293 | 296 | .subscribe(event => {
|
294 | 297 | if (!isClickInsideMenuOverlay(event.target as Element)) {
|
|
0 commit comments