Skip to content

Commit 9209a3d

Browse files
committed
fix(material-experimental/mdc-slider): fix VE bug
* in view engine, MatSliders inputs are not initialized before MatSliderThumbs constructor is called. This means we cannot initialize the slider value attribute in the constructor. To fix this, we are initializing the value attribute in ngOnInit which is still before ngAfterViewInit but after MatSliders inputs are initialized
1 parent 2b8785f commit 9209a3d

File tree

1 file changed

+8
-4
lines changed
  • src/material-experimental/mdc-slider

1 file changed

+8
-4
lines changed

src/material-experimental/mdc-slider/slider.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
Input,
2929
NgZone,
3030
OnDestroy,
31+
OnInit,
3132
Output,
3233
QueryList,
3334
ViewChild,
@@ -260,7 +261,7 @@ export class MatSliderVisualThumb implements AfterViewInit, OnDestroy {
260261
multi: true
261262
}],
262263
})
263-
export class MatSliderThumb implements AfterViewInit, ControlValueAccessor {
264+
export class MatSliderThumb implements AfterViewInit, ControlValueAccessor, OnInit {
264265

265266
// ** IMPORTANT NOTE **
266267
//
@@ -336,11 +337,14 @@ export class MatSliderThumb implements AfterViewInit, ControlValueAccessor {
336337
private readonly _elementRef: ElementRef<HTMLInputElement>) {
337338
this._document = document;
338339
this._hostElement = _elementRef.nativeElement;
339-
// By calling this in the constructor we guarantee that the sibling sliders initial value by
340-
// has already been set by the time we reach ngAfterViewInit().
341-
this._initializeInputValueAttribute();
342340
}
343341

342+
ngOnInit() {
343+
// By calling this in ngOnInit() we guarantee that the sibling sliders initial value by
344+
// has already been set by the time we reach ngAfterViewInit().
345+
this._initializeInputValueAttribute();
346+
}
347+
344348
ngAfterViewInit() {
345349
this._initializeInputState();
346350
this._initializeInputValueProperty();

0 commit comments

Comments
 (0)