Skip to content

Commit 625f792

Browse files
arturovtjelbourn
authored andcommitted
fix(input): only monitor focus origin on browser platform (#11604)
1 parent 648eb4a commit 625f792

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/lib/input/input.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,12 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
254254
}
255255

256256
ngOnInit() {
257-
this._autofillMonitor.monitor(this._elementRef).subscribe(event => {
258-
this.autofilled = event.isAutofilled;
259-
this.stateChanges.next();
260-
});
257+
if (this._platform.isBrowser) {
258+
this._autofillMonitor.monitor(this._elementRef.nativeElement).subscribe(event => {
259+
this.autofilled = event.isAutofilled;
260+
this.stateChanges.next();
261+
});
262+
}
261263
}
262264

263265
ngOnChanges() {
@@ -266,7 +268,10 @@ export class MatInput extends _MatInputMixinBase implements MatFormFieldControl<
266268

267269
ngOnDestroy() {
268270
this.stateChanges.complete();
269-
this._autofillMonitor.stopMonitoring(this._elementRef);
271+
272+
if (this._platform.isBrowser) {
273+
this._autofillMonitor.stopMonitoring(this._elementRef.nativeElement);
274+
}
270275
}
271276

272277
ngDoCheck() {

0 commit comments

Comments
 (0)