MCPcopy Create free account
hub / github.com/angular/components / MatAutocompleteTrigger

Class MatAutocompleteTrigger

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

Source from the content-addressed store, hash-verified

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

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