Skip to content

Commit c86e1ef

Browse files
authored
fix(material/slider): fix voiceover on ios (#27302)
* fix(material/slider): fix voiceover on ios * fixes issue #15037 * fixup! fix(material/slider): fix voiceover on ios * fixup! fix(material/slider): fix voiceover on ios
1 parent 3be0809 commit c86e1ef

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/material/slider/slider.spec.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,48 +90,48 @@ describe('MDC-based MatSlider', () => {
9090
it('should set the default values', () => {
9191
expect(slider.min).toBe(0);
9292
expect(slider.max).toBe(100);
93-
expect(slider.step).toBe(0);
94-
checkInput(input, {min: 0, max: 100, value: 0, step: 0, translateX: 0});
93+
expect(slider.step).toBe(1);
94+
checkInput(input, {min: 0, max: 100, value: 0, step: 1, translateX: 0});
9595
});
9696

9797
it('should update by click', fakeAsync(() => {
9898
setValueByClick(slider, input, 25);
99-
checkInput(input, {min: 0, max: 100, value: 25, step: 0, translateX: 75});
99+
checkInput(input, {min: 0, max: 100, value: 25, step: 1, translateX: 75});
100100

101101
setValueByClick(slider, input, 50);
102-
checkInput(input, {min: 0, max: 100, value: 50, step: 0, translateX: 150});
102+
checkInput(input, {min: 0, max: 100, value: 50, step: 1, translateX: 150});
103103

104104
setValueByClick(slider, input, 75);
105-
checkInput(input, {min: 0, max: 100, value: 75, step: 0, translateX: 225});
105+
checkInput(input, {min: 0, max: 100, value: 75, step: 1, translateX: 225});
106106

107107
setValueByClick(slider, input, 100);
108-
checkInput(input, {min: 0, max: 100, value: 100, step: 0, translateX: 300});
108+
checkInput(input, {min: 0, max: 100, value: 100, step: 1, translateX: 300});
109109
}));
110110

111111
it('should update by slide', fakeAsync(() => {
112112
slideToValue(slider, input, 25);
113-
checkInput(input, {min: 0, max: 100, value: 25, step: 0, translateX: 75});
113+
checkInput(input, {min: 0, max: 100, value: 25, step: 1, translateX: 75});
114114

115115
slideToValue(slider, input, 50);
116-
checkInput(input, {min: 0, max: 100, value: 50, step: 0, translateX: 150});
116+
checkInput(input, {min: 0, max: 100, value: 50, step: 1, translateX: 150});
117117

118118
slideToValue(slider, input, 75);
119-
checkInput(input, {min: 0, max: 100, value: 75, step: 0, translateX: 225});
119+
checkInput(input, {min: 0, max: 100, value: 75, step: 1, translateX: 225});
120120

121121
slideToValue(slider, input, 100);
122-
checkInput(input, {min: 0, max: 100, value: 100, step: 0, translateX: 300});
122+
checkInput(input, {min: 0, max: 100, value: 100, step: 1, translateX: 300});
123123
}));
124124

125125
it('should not slide before the track', fakeAsync(() => {
126126
slideToValue(slider, input, -10);
127127
expect(input.value).toBe(0);
128-
checkInput(input, {min: 0, max: 100, value: 0, step: 0, translateX: 0});
128+
checkInput(input, {min: 0, max: 100, value: 0, step: 1, translateX: 0});
129129
}));
130130

131131
it('should not slide past the track', fakeAsync(() => {
132132
slideToValue(slider, input, 110);
133133
expect(input.value).toBe(100);
134-
checkInput(input, {min: 0, max: 100, value: 100, step: 0, translateX: 300});
134+
checkInput(input, {min: 0, max: 100, value: 100, step: 1, translateX: 300});
135135
}));
136136

137137
// TODO(wagnermaciel): Fix this test case (behavior works as intended in browser).
@@ -140,7 +140,7 @@ describe('MDC-based MatSlider', () => {
140140
// tick(200);
141141
// fixture.detectChanges();
142142
// setValueByClick(slider, input, 25);
143-
// checkInput(input, {min: 0, max: 100, value: 25, step: 0, translateX: 75});
143+
// checkInput(input, {min: 0, max: 100, value: 25, step: 1, translateX: 75});
144144
// slider._elementRef.nativeElement.style.marginLeft = 'initial';
145145
// }));
146146
});
@@ -161,12 +161,12 @@ describe('MDC-based MatSlider', () => {
161161
}));
162162

163163
it('should set the default values', () => {
164-
checkInput(startInput, {min: 0, max: 100, value: 0, step: 0, translateX: 0});
165-
checkInput(endInput, {min: 0, max: 100, value: 100, step: 0, translateX: 300});
164+
checkInput(startInput, {min: 0, max: 100, value: 0, step: 1, translateX: 0});
165+
checkInput(endInput, {min: 0, max: 100, value: 100, step: 1, translateX: 300});
166166

167167
expect(slider.min).toBe(0);
168168
expect(slider.max).toBe(100);
169-
expect(slider.step).toBe(0);
169+
expect(slider.step).toBe(1);
170170
});
171171

172172
it('should update by start input click', fakeAsync(() => {
@@ -1373,16 +1373,16 @@ describe('MDC-based MatSlider', () => {
13731373
});
13741374

13751375
it('should sync the value binding in both directions', fakeAsync(() => {
1376-
checkInput(input, {min: 0, max: 100, value: 0, step: 0, translateX: 0});
1376+
checkInput(input, {min: 0, max: 100, value: 0, step: 1, translateX: 0});
13771377

13781378
slideToValue(slider, input, 10);
13791379
expect(fixture.componentInstance.value).toBe(10);
1380-
checkInput(input, {min: 0, max: 100, value: 10, step: 0, translateX: 30});
1380+
checkInput(input, {min: 0, max: 100, value: 10, step: 1, translateX: 30});
13811381

13821382
fixture.componentInstance.value = 20;
13831383
fixture.detectChanges();
13841384
expect(fixture.componentInstance.value).toBe(20);
1385-
checkInput(input, {min: 0, max: 100, value: 20, step: 0, translateX: 60});
1385+
checkInput(input, {min: 0, max: 100, value: 20, step: 1, translateX: 60});
13861386
}));
13871387
});
13881388

src/material/slider/slider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ export class MatSlider
283283
this._updateStep(step);
284284
}
285285
}
286-
private _step: number = 0;
286+
private _step: number = 1;
287287

288288
private _updateStep(step: number): void {
289289
this._step = step;

src/material/slider/testing/slider-harness.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ describe('MDC-based MatSliderHarness', () => {
9696
await parallel(() => {
9797
return sliders.map(slider => slider.getStep());
9898
}),
99-
).toEqual([0, fixture.componentInstance.rangeSliderStep]);
99+
).toEqual([1, fixture.componentInstance.rangeSliderStep]);
100100
});
101101

102102
it('should get the position of a slider thumb in a range slider', async () => {

0 commit comments

Comments
 (0)