Skip to content

Commit d114ce7

Browse files
authored
fix: hide weekdays from assistive technologies (#4658)
1 parent 106fc4c commit d114ce7

4 files changed

Lines changed: 28 additions & 5 deletions

File tree

‎packages/date-picker/src/vaadin-month-calendar.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
8080
is="dom-repeat"
8181
items="[[_getWeekDayNames(i18n.weekdays, i18n.weekdaysShort, showWeekNumbers, i18n.firstDayOfWeek)]]"
8282
>
83-
<th role="columnheader" part="weekday" scope="col" abbr$="[[item.weekDay]]">[[item.weekDayShort]]</th>
83+
<th role="columnheader" part="weekday" scope="col" abbr$="[[item.weekDay]]" aria-hidden="true">
84+
[[item.weekDayShort]]
85+
</th>
8486
</template>
8587
</tr>
8688
</thead>

‎packages/date-picker/test/basic.test.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ describe('basic features', () => {
304304
it('should notify i18n mutation to children', () => {
305305
const monthCalendar = overlayContent.$.monthScroller.querySelector('vaadin-month-calendar');
306306
const weekdays = monthCalendar.$.monthGrid.querySelectorAll('[part="weekday"]:not(:empty)');
307-
const weekdayTitles = Array.prototype.map.call(weekdays, (weekday) => weekday.textContent);
307+
const weekdayTitles = Array.prototype.map.call(weekdays, (weekday) => weekday.textContent.trim());
308308
expect(weekdayTitles).to.eql(['ma', 'ti', 'ke', 'to', 'pe', 'la', 'su']);
309309
});
310310

‎packages/date-picker/test/dom/__snapshots__/month-calendar.test.snap.js‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ snapshots["vaadin-month-calendar shadow default"] =
6464
</th>
6565
<th
6666
abbr="Sunday"
67+
aria-hidden="true"
6768
part="weekday"
6869
role="columnheader"
6970
scope="col"
@@ -72,6 +73,7 @@ snapshots["vaadin-month-calendar shadow default"] =
7273
</th>
7374
<th
7475
abbr="Monday"
76+
aria-hidden="true"
7577
part="weekday"
7678
role="columnheader"
7779
scope="col"
@@ -80,6 +82,7 @@ snapshots["vaadin-month-calendar shadow default"] =
8082
</th>
8183
<th
8284
abbr="Tuesday"
85+
aria-hidden="true"
8386
part="weekday"
8487
role="columnheader"
8588
scope="col"
@@ -88,6 +91,7 @@ snapshots["vaadin-month-calendar shadow default"] =
8891
</th>
8992
<th
9093
abbr="Wednesday"
94+
aria-hidden="true"
9195
part="weekday"
9296
role="columnheader"
9397
scope="col"
@@ -96,6 +100,7 @@ snapshots["vaadin-month-calendar shadow default"] =
96100
</th>
97101
<th
98102
abbr="Thursday"
103+
aria-hidden="true"
99104
part="weekday"
100105
role="columnheader"
101106
scope="col"
@@ -104,6 +109,7 @@ snapshots["vaadin-month-calendar shadow default"] =
104109
</th>
105110
<th
106111
abbr="Friday"
112+
aria-hidden="true"
107113
part="weekday"
108114
role="columnheader"
109115
scope="col"
@@ -112,6 +118,7 @@ snapshots["vaadin-month-calendar shadow default"] =
112118
</th>
113119
<th
114120
abbr="Saturday"
121+
aria-hidden="true"
115122
part="weekday"
116123
role="columnheader"
117124
scope="col"
@@ -467,6 +474,7 @@ snapshots["vaadin-month-calendar shadow max date"] =
467474
</th>
468475
<th
469476
abbr="Sunday"
477+
aria-hidden="true"
470478
part="weekday"
471479
role="columnheader"
472480
scope="col"
@@ -475,6 +483,7 @@ snapshots["vaadin-month-calendar shadow max date"] =
475483
</th>
476484
<th
477485
abbr="Monday"
486+
aria-hidden="true"
478487
part="weekday"
479488
role="columnheader"
480489
scope="col"
@@ -483,6 +492,7 @@ snapshots["vaadin-month-calendar shadow max date"] =
483492
</th>
484493
<th
485494
abbr="Tuesday"
495+
aria-hidden="true"
486496
part="weekday"
487497
role="columnheader"
488498
scope="col"
@@ -491,6 +501,7 @@ snapshots["vaadin-month-calendar shadow max date"] =
491501
</th>
492502
<th
493503
abbr="Wednesday"
504+
aria-hidden="true"
494505
part="weekday"
495506
role="columnheader"
496507
scope="col"
@@ -499,6 +510,7 @@ snapshots["vaadin-month-calendar shadow max date"] =
499510
</th>
500511
<th
501512
abbr="Thursday"
513+
aria-hidden="true"
502514
part="weekday"
503515
role="columnheader"
504516
scope="col"
@@ -507,6 +519,7 @@ snapshots["vaadin-month-calendar shadow max date"] =
507519
</th>
508520
<th
509521
abbr="Friday"
522+
aria-hidden="true"
510523
part="weekday"
511524
role="columnheader"
512525
scope="col"
@@ -515,6 +528,7 @@ snapshots["vaadin-month-calendar shadow max date"] =
515528
</th>
516529
<th
517530
abbr="Saturday"
531+
aria-hidden="true"
518532
part="weekday"
519533
role="columnheader"
520534
scope="col"
@@ -907,6 +921,7 @@ snapshots["vaadin-month-calendar shadow week numbers"] =
907921
</th>
908922
<th
909923
abbr="Monday"
924+
aria-hidden="true"
910925
part="weekday"
911926
role="columnheader"
912927
scope="col"
@@ -915,6 +930,7 @@ snapshots["vaadin-month-calendar shadow week numbers"] =
915930
</th>
916931
<th
917932
abbr="Tuesday"
933+
aria-hidden="true"
918934
part="weekday"
919935
role="columnheader"
920936
scope="col"
@@ -923,6 +939,7 @@ snapshots["vaadin-month-calendar shadow week numbers"] =
923939
</th>
924940
<th
925941
abbr="Wednesday"
942+
aria-hidden="true"
926943
part="weekday"
927944
role="columnheader"
928945
scope="col"
@@ -931,6 +948,7 @@ snapshots["vaadin-month-calendar shadow week numbers"] =
931948
</th>
932949
<th
933950
abbr="Thursday"
951+
aria-hidden="true"
934952
part="weekday"
935953
role="columnheader"
936954
scope="col"
@@ -939,6 +957,7 @@ snapshots["vaadin-month-calendar shadow week numbers"] =
939957
</th>
940958
<th
941959
abbr="Friday"
960+
aria-hidden="true"
942961
part="weekday"
943962
role="columnheader"
944963
scope="col"
@@ -947,6 +966,7 @@ snapshots["vaadin-month-calendar shadow week numbers"] =
947966
</th>
948967
<th
949968
abbr="Saturday"
969+
aria-hidden="true"
950970
part="weekday"
951971
role="columnheader"
952972
scope="col"
@@ -955,6 +975,7 @@ snapshots["vaadin-month-calendar shadow week numbers"] =
955975
</th>
956976
<th
957977
abbr="Sunday"
978+
aria-hidden="true"
958979
part="weekday"
959980
role="columnheader"
960981
scope="col"

‎packages/date-picker/test/month-calendar.test.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ describe('vaadin-month-calendar', () => {
4040

4141
it('should render days in correct order by default', () => {
4242
const weekdays = monthCalendar.shadowRoot.querySelectorAll('[part="weekday"]:not(:empty)');
43-
const weekdayTitles = Array.from(weekdays).map((weekday) => weekday.textContent);
43+
const weekdayTitles = Array.from(weekdays).map((weekday) => weekday.textContent.trim());
4444
expect(weekdayTitles).to.eql(['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']);
4545
});
4646

4747
it('should render days in correct order by first day of week', async () => {
4848
monthCalendar.set('i18n.firstDayOfWeek', 1); // Start from Monday.
4949
await aTimeout();
5050
const weekdays = monthCalendar.shadowRoot.querySelectorAll('[part="weekday"]:not(:empty)');
51-
const weekdayTitles = Array.from(weekdays).map((weekday) => weekday.textContent);
51+
const weekdayTitles = Array.from(weekdays).map((weekday) => weekday.textContent.trim());
5252
expect(weekdayTitles).to.eql(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']);
5353
});
5454

@@ -170,7 +170,7 @@ describe('vaadin-month-calendar', () => {
170170

171171
it('should render weekdays in correct locale', () => {
172172
const weekdays = monthCalendar.shadowRoot.querySelectorAll('[part="weekday"]:not(:empty)');
173-
const weekdayTitles = Array.from(weekdays).map((weekday) => weekday.textContent);
173+
const weekdayTitles = Array.from(weekdays).map((weekday) => weekday.textContent.trim());
174174
expect(weekdayTitles).to.eql(['ma', 'ti', 'ke', 'to', 'pe', 'la', 'su']);
175175
});
176176

0 commit comments

Comments
 (0)