Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#9474 closed bug (duplicate)

Datepicker Keyboard Shortcuts Navigate Incorrectly with Bounded Multi-Month Options Set

Reported by: marc.thorson Owned by:
Priority: minor Milestone: none
Component: ui.datepicker Version: 1.10.3
Keywords: Cc:
Blocked by: Blocking:


Version Tested: jQuery UI 1.10.3; OS Tested: Windows 7; Browsers Tested: IE, Firefox, Chrome (bug most likely impacts all browsers and platforms)

When defining a Datepicker object with multiple months (numberOfMonths > 1) and fixed bounds (minDate and maxDate are defined), the keyboard shortcuts navigate improperly when the focus goes into the second month displayed. A bug exists in the jQuery UI Datepicker codebase which causes the focus to incorrectly jump back into the first month upon the next keyboard command.

To re-create the issue, create a new two-month Datepicker object with minimum and maximum dates that define a 45-day window around the current/default date. For example, if today's date is August 4, a minimum date of August 1 and maximum date of September 15 would produce a Datepicker object with this issue. Once defined, use the keyboard commands (e.g. Ctrl+Right) to navigate forward through the calendar. When the focus gets to the second month displayed, the script incorrectly jumps back into the first month displayed, which mistakenly makes it impossible for a keyboard user to effectively choose any date outside of the first month.

Upon further inspection of the code, the following modification appears to resolve the issue:

/* Adjust one of the date sub-fields. */

_adjustInstDate: function(inst, offset, period) {

var year = inst.selectedYear + (period === "Y" ? offset : 0),

month = inst.selectedMonth + (period === "M" ? offset : 0),

day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),

date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));

Detailed examples of the bug and fix suggestion are provided at the following URLs:

Bug Example:


Fix Example:

Change History (2)

comment:1 Changed 9 years ago by tj.vantoll

Resolution: duplicate
Status: newclosed

Duplicate of #7956.
Hi marc.thorson,

This is a duplicate of #7956 but I'm going to move your comments and test cases over there as this is a lot better explanation of the problem. Thanks!

comment:2 in reply to:  1 Changed 9 years ago by marc.thorson

Replying to tj.vantoll:

You're welcome. Glad I could help. I enjoy making the web accessible for all! Feel free to let me know if you need any more assistance.

Note: See TracTickets for help on using tickets.