This is a migrated thread and some comments may be shown as answers.

Setting "aria-label" on DatePicker and DateTimePicker Calendar/Clock icons

2 Answers 2212 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 12 Feb 2016, 01:04 PM

How can I specify the text to be displayed in JAWS for the icons in DatePicker and DateTimePicker?

By default, when I use JAWS to look at the elements of the screen, the following is displayed for DatePickers and DateTimePickers:

DatePicker

  Hire Date Edit MM/DD/YYYY
  select Button

DateTimePicker

  Shift Start Edit MM/DD/YYYY H:M t
  select Button
  
select Button

These "select Button" entries correspond to the calendar icon (for both) and  the clock icon (for DateTimePicker). 

When I have multiple buttons on the screen (or even when it's a DateTimePicker), there are multiple entries that say "select Button" and the user doesn't know what they are.  I'd like to set them so that they'd say something like the following:

DatePicker 

  Hire Date Edit MM/DD/YYYY
  Set Hire Date Button

DateTimePicker

  Shift Start Edit MM/DD/YYYY H:M t
  Set Shift Start Date Button
  Set Shift Start Time Button

 I can do this by manually adding the "aria-label" attribute to the appropriate span ("k-icon k-i-calendar" for the calendar, "k-icon k-i-clock" for the clock) when debugging (e.g., F12), but can't seem to figure out how to do it on the control itself in code.  Here's how I have the controls defined: 

01./* HTML Body */
02.  
03.<input id="hireDatePicker" aria-label="@UserInterface.NewHire_HireDatePicker_Text" />
04.<input id="shiftStartDateTimePicker" aria-label="@UserInterface.NewHire_ShiftStartDateTimePicker_Text" />
05.  
06./* $(document).ready(function () */
07.  
08.$('#hireDatePicker').kendoDatePicker({
09.  value:new Date(),
10.  ARIATemplate: "Date: #=kendo.toString(data.current, 'G')#"
11.});
12.  
13.$('#shiftStartDateTimePicker').kendoDateTimePicker({
14.  value:new Date(),
15.  interval:60,
16.  change: startDateTimeChange,
17.  ARIATemplate: "Date: #=kendo.toString(data.current, 'G')#"
18.});

2 Answers, 1 is accepted

Sort by
0
Matt
Top achievements
Rank 1
answered on 12 Feb 2016, 04:20 PM

Alright...progress, but I'm still left curious as to whether there's an easier way.

I'm able to add the "aria-label" attribute to the span that contains the calendar and clock icons, but it still doesn't appear in JAWS.  

$('#dateTimeSearchPadding span span span span.k-i-calendar').attr("aria-label", "Set Hire Date");

Why?  Because of "select" between the <span ...></span> tags:

<span class="k-icon k-i-calendar" aria-label="Set Hire Date" unselectable="on">select</span>

So, I switched gears and figured out how to change the text, which I did via the following (I have a <div> around my DatePickers and DateTimePickers).

$('#dateTimeSearchPadding span span span span.k-i-calendar').html("Set Hire Date");

While this works for what I need, I'm left wondering if there's something accessible via the DatePicker and DateTimePicker widgets:  Is there or are we required to jump through hoops such as this for getting into the guts of these controls?

0
Georgi Krustev
Telerik team
answered on 16 Feb 2016, 08:55 AM
Hello Matt,

Indeed, the widget does not expose a way to control the content of the toggle buttons. The only way to change that test is to use jQuery, like you did.

I logged an enhancement task in our product back log that will allow you to control the text too:
Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Date/Time Pickers
Asked by
Matt
Top achievements
Rank 1
Answers by
Matt
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or