Skip to content

Commit 9176e11

Browse files
Merge pull request #2 from UniversityofWarwick/SBTWO-9429
SBTWO-9429 aria-current set to date on current date cells
2 parents 8fcc376 + 1f25f70 commit 9176e11

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

js/datepicker.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,8 @@
800800
*
801801
*/
802802
Datepicker.prototype.populateDaysCalendar = function() {
803+
const today = new Date();
804+
today.setHours(0,0,0,0);
803805
this.log('populateDaysCalendar');
804806
this.$calendar.find('.datepicker-bn-prev-label').html(this.options.prevButtonLabel);
805807
this.$calendar.find('.datepicker-bn-next-label').html(this.options.nextButtonLabel);
@@ -881,6 +883,7 @@
881883
var date = new Date(this.year, this.month, curDay, 0, 0, 0, 0);
882884
var longdate = this.formatDate(date, this.options.titleFormat);
883885
var curDayClass = curDay == this.date && this.month == this.curMonth && this.year == this.curYear ? ' curDay' : '';
886+
const isToday = date.toISOString() === today.toISOString();
884887
if (isYearDisabled || isMonthDisabled) {
885888
gridCells += '\t\t<td id="cell' + curDay + '-' + this.id + '" class="day unselectable' + curDayClass + '"';
886889
} else if ($.inArray(weekday, this.options.daysOfWeekDisabled) > -1) {
@@ -899,6 +902,9 @@
899902
gridCells += ' data-value="' + curDay + '"';
900903
gridCells += ' title="' + longdate + '"';
901904
gridCells += ' aria-label="' + longdate + '"';
905+
if (isToday) {
906+
gridCells += 'aria-current="date"';
907+
}
902908
gridCells += ' headers="day' + weekday + '-header-' + this.id + '" role="gridcell" tabindex="-1" aria-selected="false">' + curDay;
903909
gridCells += '</td>';
904910
if (weekday == lastDayOfWeek && curDay < numDays) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@universityofwarwick/ab-datepicker",
3-
"version": "2.2.2",
3+
"version": "2.2.3",
44
"description": "An accessible and bootstrap compatible datepicker",
55
"main": "js/datepicker.js",
66
"directories": {

0 commit comments

Comments
 (0)