Skip to content

Commit 0b5b624

Browse files
mmalerbajelbourn
authored andcommitted
fix(slider): add aria-orientation (#4602)
1 parent 07a82ed commit 0b5b624

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

src/demo-app/slider/slider-demo.html

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,60 @@
11
<h1>Default Slider</h1>
2-
Label <md-slider #slidey></md-slider>
2+
Label <md-slider #slidey aria-label="Basic slider"></md-slider>
33
{{slidey.value}}
44

55
<h1>Colors</h1>
6-
<md-slider color="primary" value="50" thumbLabel></md-slider>
7-
<md-slider color="accent" value="50" thumbLabel></md-slider>
8-
<md-slider color="warn" value="50" thumbLabel></md-slider>
6+
<md-slider color="primary" value="50" thumbLabel aria-label="Primary color slider"></md-slider>
7+
<md-slider color="accent" value="50" thumbLabel aria-label="Accent color slider"></md-slider>
8+
<md-slider color="warn" value="50" thumbLabel aria-label="Warn color slider"></md-slider>
99

1010
<h1>Slider with Min and Max</h1>
11-
<input [(ngModel)]="min">
12-
<md-slider [min]="min" [max]="max" tickInterval="5" #slider2></md-slider>
11+
<input [(ngModel)]="min" type="number">
12+
<md-slider [min]="min" [max]="max" tickInterval="5" #slider2 aria-label="Min & max slider">
13+
</md-slider>
1314
{{slider2.value}}
14-
<input [(ngModel)]="max">
15+
<input [(ngModel)]="max" type="number">
1516

1617
<h1>Disabled Slider</h1>
17-
<md-slider disabled [(ngModel)]="disabledValue" [tickInterval]="1"></md-slider>
18-
<input [(ngModel)]="disabledValue">
18+
<md-slider disabled [(ngModel)]="disabledValue" [tickInterval]="1" aria-label="Disabled slider">
19+
</md-slider>
20+
<input [(ngModel)]="disabledValue" type="number">
1921

2022
<h1>Slider with set value</h1>
21-
<md-slider value="43"></md-slider>
23+
<md-slider value="43" aria-label="Initial value slider"></md-slider>
2224

2325
<h1>Slider with step defined</h1>
24-
<md-slider min="1" max="100" step="20" #slider5></md-slider>
26+
<md-slider min="1" max="100" step="20" #slider5 aria-label="Slider with step"></md-slider>
2527
{{slider5.value}}
2628

2729
<h1>Slider with set tick interval</h1>
28-
<md-slider tickInterval="auto"></md-slider>
29-
<md-slider tickInterval="9"></md-slider>
30+
<md-slider tickInterval="auto" aria-label="Slider with auto ticks"></md-slider>
31+
<md-slider tickInterval="9" aria-label="Slider with ticks"></md-slider>
3032

3133
<h1>Slider with Thumb Label</h1>
32-
<md-slider thumbLabel></md-slider>
34+
<md-slider thumbLabel aria-label="Slider with thumb label"></md-slider>
3335

3436
<h1>Slider with one-way binding</h1>
35-
<md-slider [value]="val" step="40"></md-slider>
36-
<input [(ngModel)]="val">
37+
<md-slider [value]="val" step="40" aria-label="Slider with value binding"></md-slider>
38+
<input [(ngModel)]="val" type="number">
3739

3840
<h1>Slider with two-way binding</h1>
39-
<md-slider [(ngModel)]="demo" step="40"></md-slider>
40-
<input [(ngModel)]="demo">
41+
<md-slider [(ngModel)]="demo" step="40" aria-label="Slider with ngModel"></md-slider>
42+
<input [(ngModel)]="demo" type="number">
4143

4244
<h1>Inverted slider</h1>
43-
<md-slider invert value="50" tickInterval="5"></md-slider>
45+
<md-slider invert value="50" tickInterval="5" aria-label="Inverted slider"></md-slider>
4446

4547
<h1>Vertical slider</h1>
46-
<md-slider vertical thumbLabel tickInterval="auto" value="50"></md-slider>
48+
<md-slider vertical thumbLabel tickInterval="auto" value="50" aria-label="Vertical slider">
49+
</md-slider>
4750

4851
<h1>Inverted vertical slider</h1>
49-
<md-slider vertical invert thumbLabel tickInterval="auto" value="50"></md-slider>
52+
<md-slider vertical invert thumbLabel tickInterval="auto" value="50"
53+
aria-label="Inverted vertical slider">
54+
</md-slider>
5055

5156
<md-tab-group>
5257
<md-tab label="One">
53-
<md-slider min="1" max="5" value="3"></md-slider>
58+
<md-slider min="1" max="5" value="3" aria-label="Slider in a tab"></md-slider>
5459
</md-tab>
5560
</md-tab-group>

src/lib/slider/slider.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ describe('MdSlider', () => {
154154
// Some browsers use '0' and some use '0px', so leave off the closing paren.
155155
expect(trackFillElement.style.transform).toContain('translateX(0');
156156
});
157+
158+
it('should have aria-orientation horizontal', () => {
159+
expect(sliderNativeElement.getAttribute('aria-orientation')).toEqual('horizontal');
160+
});
157161
});
158162

159163
describe('disabled slider', () => {
@@ -1156,6 +1160,10 @@ describe('MdSlider', () => {
11561160

11571161
expect(trackFillElement.style.transform).toContain('scaleY(0.39)');
11581162
});
1163+
1164+
it('should have aria-orientation vertical', () => {
1165+
expect(sliderNativeElement.getAttribute('aria-orientation')).toEqual('vertical');
1166+
});
11591167
});
11601168
});
11611169

src/lib/slider/slider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export const _MdSliderMixinBase = mixinDisabled(MdSliderBase);
9191
'[attr.aria-valuemax]': 'max',
9292
'[attr.aria-valuemin]': 'min',
9393
'[attr.aria-valuenow]': 'value',
94+
'[attr.aria-orientation]': 'vertical ? "vertical" : "horizontal"',
9495
'[class.mat-primary]': 'color == "primary"',
9596
'[class.mat-accent]': 'color != "primary" && color != "warn"',
9697
'[class.mat-warn]': 'color == "warn"',

0 commit comments

Comments
 (0)