Skip to content

Commit

Permalink
fix(autocomplete): incorrectly detecting shadow DOM when inserted thr…
Browse files Browse the repository at this point in the history
…ough an embedded view (#19332)
  • Loading branch information
crisbeto authored and mmalerba committed May 15, 2020
1 parent c17b150 commit 8d79d73
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/material/autocomplete/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, AfterViewIn
const window = this._getWindow();

if (typeof window !== 'undefined') {
this._zone.runOutsideAngular(() => {
window.addEventListener('blur', this._windowBlurHandler);
});

this._isInsideShadowRoot = !!_getShadowRoot(this._element.nativeElement);
this._zone.runOutsideAngular(() => window.addEventListener('blur', this._windowBlurHandler));
}
}

Expand Down Expand Up @@ -619,6 +615,12 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, AfterViewIn
throw getMatAutocompleteMissingPanelError();
}

// We want to resolve this once, as late as possible so that we can be
// sure that the element has been moved into its final place in the DOM.
if (this._isInsideShadowRoot == null) {
this._isInsideShadowRoot = !!_getShadowRoot(this._element.nativeElement);
}

let overlayRef = this._overlayRef;

if (!overlayRef) {
Expand Down

0 comments on commit 8d79d73

Please sign in to comment.