@@ -358,21 +358,23 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, AfterViewIn
358358
359359 /** Stream of clicks outside of the autocomplete panel. */
360360 private _getOutsideClickStream ( ) : Observable < any > {
361+ // Use capturing so we can close even if propagation is stopped.
362+ const eventOptions = { capture : true } ;
361363 return merge (
362- fromEvent ( this . _document , 'click' ) as Observable < MouseEvent > ,
363- fromEvent ( this . _document , 'touchend' ) as Observable < TouchEvent > )
364- . pipe ( filter ( event => {
365- // If we're in the Shadow DOM, the event target will be the shadow root, so we have to
366- // fall back to check the first element in the path of the click event.
367- const clickTarget =
368- ( this . _isInsideShadowRoot && event . composedPath ? event . composedPath ( ) [ 0 ] :
369- event . target ) as HTMLElement ;
370- const formField = this . _formField ? this . _formField . _elementRef . nativeElement : null ;
371-
372- return this . _overlayAttached && clickTarget !== this . _element . nativeElement &&
373- ( ! formField || ! formField . contains ( clickTarget ) ) &&
374- ( ! ! this . _overlayRef && ! this . _overlayRef . overlayElement . contains ( clickTarget ) ) ;
375- } ) ) ;
364+ fromEvent ( this . _document , 'click' , eventOptions ) as Observable < MouseEvent > ,
365+ fromEvent ( this . _document , 'touchend' , eventOptions ) as Observable < TouchEvent >
366+ ) . pipe ( filter ( event => {
367+ // If we're in the Shadow DOM, the event target will be the shadow root, so we have to
368+ // fall back to check the first element in the path of the click event.
369+ const clickTarget =
370+ ( this . _isInsideShadowRoot && event . composedPath ? event . composedPath ( ) [ 0 ] :
371+ event . target ) as HTMLElement ;
372+ const formField = this . _formField ? this . _formField . _elementRef . nativeElement : null ;
373+
374+ return this . _overlayAttached && clickTarget !== this . _element . nativeElement &&
375+ ( ! formField || ! formField . contains ( clickTarget ) ) &&
376+ ( ! ! this . _overlayRef && ! this . _overlayRef . overlayElement . contains ( clickTarget ) ) ;
377+ } ) ) ;
376378 }
377379
378380 // Implemented as part of ControlValueAccessor.
0 commit comments