File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
src/material/form-field/directives Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import {
17
17
Output ,
18
18
} from '@angular/core' ;
19
19
import { SharedResizeObserver } from '../resize-observer' ;
20
+ import { Platform } from '@angular/cdk/platform' ;
20
21
21
22
/**
22
23
* Internal directive that maintains a MDC floating label. This directive does not
@@ -70,6 +71,8 @@ export class MatFormFieldFloatingLabel implements OnDestroy {
70
71
71
72
private _ngZone = inject ( NgZone ) ;
72
73
74
+ private _platform = inject ( Platform ) ;
75
+
73
76
private _resizeObserver = inject ( SharedResizeObserver ) ;
74
77
75
78
private _stopResizeObserver = ( ) => { } ;
@@ -91,12 +94,14 @@ export class MatFormFieldFloatingLabel implements OnDestroy {
91
94
}
92
95
93
96
private _startResizeObserver ( ) {
94
- this . _stopResizeObserver ( ) ;
95
- this . _stopResizeObserver = this . _ngZone . runOutsideAngular ( ( ) =>
96
- this . _resizeObserver . observe ( this . _elementRef . nativeElement , ( ) => this . resized . emit ( ) , {
97
- box : 'border-box' ,
98
- } ) ,
99
- ) ;
97
+ if ( this . _platform . isBrowser ) {
98
+ this . _stopResizeObserver ( ) ;
99
+ this . _stopResizeObserver = this . _ngZone . runOutsideAngular ( ( ) =>
100
+ this . _resizeObserver . observe ( this . _elementRef . nativeElement , ( ) => this . resized . emit ( ) , {
101
+ box : 'border-box' ,
102
+ } ) ,
103
+ ) ;
104
+ }
100
105
}
101
106
}
102
107
You can’t perform that action at this time.
0 commit comments