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

Class MatAutocompleteTrigger

src/material/autocomplete/autocomplete-trigger.ts:122–1026  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120 providers: [MAT_AUTOCOMPLETE_VALUE_ACCESSOR],
121})
122export class MatAutocompleteTrigger
123 implements ControlValueAccessor, AfterViewInit, OnChanges, OnDestroy
124{
125 private _environmentInjector = inject(EnvironmentInjector);
126 private _element = inject<ElementRef<HTMLInputElement>>(ElementRef);
127 private _injector = inject(Injector);
128 private _viewContainerRef = inject(ViewContainerRef);
129 private _zone = inject(NgZone);
130 private _changeDetectorRef = inject(ChangeDetectorRef);
131 private _dir = inject(Directionality, {optional: true});
132 private _formField = inject<MatFormField | null>(MAT_FORM_FIELD, {optional: true, host: true});
133 private _viewportRuler = inject(ViewportRuler);
134 private _scrollStrategy = inject(MAT_AUTOCOMPLETE_SCROLL_STRATEGY);
135 private _renderer = inject(Renderer2);
136 private _animationsDisabled = _animationsDisabled();
137 private _defaults = inject<MatAutocompleteDefaultOptions | null>(
138 MAT_AUTOCOMPLETE_DEFAULT_OPTIONS,
139 {optional: true},
140 );
141
142 private _overlayRef: OverlayRef | null = null;
143 private _portal!: TemplatePortal;
144 private _componentDestroyed = false;
145 private _initialized = new Subject();
146 private _keydownSubscription: Subscription | undefined;
147 private _outsideClickSubscription: Subscription | undefined;
148 private _cleanupWindowBlur: (() => void) | undefined;
149
150 /** Old value of the native input. Used to work around issues with the `input` event on IE. */
151 private _previousValue: string | number | null = null;
152
153 /** Value of the input element when the panel was attached (even if there are no options). */
154 private _valueOnAttach: string | number | null = null;
155
156 /** Value on the previous keydown event. */
157 private _valueOnLastKeydown: string | null = null;
158
159 /** Strategy that is used to position the panel. */
160 private _positionStrategy!: FlexibleConnectedPositionStrategy;
161
162 /** Whether or not the label state is being overridden. */
163 private _manuallyFloatingLabel = false;
164
165 /** The subscription for closing actions (some are bound to document). */
166 private _closingActionsSubscription!: Subscription;
167
168 /** Subscription to viewport size changes. */
169 private _viewportSubscription = Subscription.EMPTY;
170
171 /** Implements BreakpointObserver to be used to detect handset landscape */
172 private _breakpointObserver = inject(BreakpointObserver);
173 private _handsetLandscapeSubscription = Subscription.EMPTY;
174
175 /**
176 * Whether the autocomplete can open the next time it is focused. Used to prevent a focused,
177 * closed autocomplete from being reopened if the user switches to another browser tab and then
178 * comes back.
179 */

Callers

nothing calls this directly

Calls 7

_hasFocusMethod · 0.95
_resetActiveItemMethod · 0.95
_animationsDisabledFunction · 0.90
coerceArrayFunction · 0.90
hasModifierKeyFunction · 0.90
nextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…