Skip to content

Commit 4ae4fe2

Browse files
committed
fix(material/slider): tick marks not showing dynamically (#31608)
Fixes that if `showTickMarks` is `false` initially and then switches to `true`, the slider wasn't updating to show the tick marks. Fixes #31590. (cherry picked from commit 9e14c55)
1 parent b5fb4cb commit 4ae4fe2

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

goldens/material/slider/index.api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider {
103103
}): void;
104104
// (undocumented)
105105
_setTransition(withAnimation: boolean): void;
106-
showTickMarks: boolean;
106+
get showTickMarks(): boolean;
107+
set showTickMarks(value: boolean);
107108
// (undocumented)
108109
_startThumbTransform: string;
109110
protected startValueIndicatorText: string;

src/material/slider/slider.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,18 @@ export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider {
132132

133133
/** Whether the slider displays tick marks along the slider track. */
134134
@Input({transform: booleanAttribute})
135-
showTickMarks: boolean = false;
135+
get showTickMarks(): boolean {
136+
return this._showTickMarks;
137+
}
138+
set showTickMarks(value: boolean) {
139+
this._showTickMarks = value;
140+
141+
if (this._hasViewInitialized) {
142+
this._updateTickMarkUI();
143+
this._updateTickMarkTrackUI();
144+
}
145+
}
146+
private _showTickMarks: boolean = false;
136147

137148
/** The minimum value that the slider can have. */
138149
@Input({transform: numberAttribute})

0 commit comments

Comments
 (0)