Skip to content

Commit fb570dd

Browse files
committed
fixup! fix(material/slider): update inactive input width on value change
1 parent 06624e7 commit fb570dd

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/material/slider/slider-input.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,21 @@ export class MatSliderThumb implements _MatSliderThumb, OnDestroy, ControlValueA
9898
if (this._isActive) {
9999
return;
100100
}
101-
this._hostElement.value = stringValue;
101+
this._setValue(stringValue);
102+
}
103+
104+
/**
105+
* Handles programmatic value setting. This has been split out to
106+
* allow the range thumb to override it and add additional necessary logic.
107+
*/
108+
protected _setValue(value: string) {
109+
this._hostElement.value = value;
102110
this._updateThumbUIByValue();
103111
this._slider._onValueChange(this);
104112
this._cdr.detectChanges();
105113
this._slider._cdr.markForCheck();
106114
}
115+
107116
/** Event emitted when the `value` is changed. */
108117
@Output() readonly valueChange: EventEmitter<number> = new EventEmitter<number>();
109118

@@ -793,4 +802,10 @@ export class MatSliderRangeThumb extends MatSliderThumb implements _MatSliderRan
793802
this._updateSibling();
794803
}
795804
}
805+
806+
override _setValue(value: string) {
807+
super._setValue(value);
808+
this._updateWidthInactive();
809+
this._updateSibling();
810+
}
796811
}

src/material/slider/slider.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,6 @@ export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider {
610610
return;
611611
}
612612

613-
this._updateWidthInactive();
614613
this._updateValueIndicatorUI(source);
615614
this._updateTickMarkUI();
616615
this._cdr.detectChanges();
@@ -672,13 +671,6 @@ export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider {
672671
return endInput.translateX - startInput.translateX < 20;
673672
}
674673

675-
private _updateWidthInactive(): void {
676-
const eInput = this._getInput(_MatThumb.END);
677-
const sInput = this._getInput(_MatThumb.START);
678-
eInput?._updateWidthInactive();
679-
sInput?._updateWidthInactive();
680-
}
681-
682674
/**
683675
* Updates the class names of overlapping slider thumbs so
684676
* that the current active thumb is styled to be on "top".

0 commit comments

Comments
 (0)