Closed GoogleCodeExporter closed 8 years ago
Replication:
1. select a date (any method)
2. reopen the datepicker, use ctrl-arrow keys to select a different date. Note:
the new date must be before the previously selected date. Press enter.
Expected output: field changes to new date.
Actual output: field does not change to new date.
Problem code:
...
_doKeyDown: function(event) {
...
case 13: var sel = $('td.' + $.datepicker._dayOverClass,
inst.dpDiv).add($('td.' + $.datepicker._currentClass, inst.dpDiv));
Bug info:
The intended behaviour here when enter is pressed is to update the state and
field with the newly selected date.
It builds an array, the first element is the dayOverClass, the newly selected
date. The second element is the fallback, the previously selected date.
However, the method used to build this collection, the add() function, does not
guarantee that new elements will be appended to the end of the collection. In
fact, it uses DOM ordering. Therefore, if your newly selected date is after the
old date, you're fine, but if it's before, the order of the collection is
backwards and the code uses the wrong date.
Code fix:
Replace:
case 13: var sel = $('td.' + $.datepicker._dayOverClass,
inst.dpDiv).add($('td.' + $.datepicker._currentClass, inst.dpDiv));
With:
case 13: var sel = [$('td.' + $.datepicker._dayOverClass, inst.dpDiv), $('td.'
+ $.datepicker._currentClass, inst.dpDiv)];
Original comment by mcn...@gmail.com
on 7 Jul 2010 at 12:36
http://code.google.com/p/jquery-datepicker/wiki/NotTheUIDatePicker
Original comment by kelvin.l...@gmail.com
on 11 Jul 2010 at 1:03
Original issue reported on code.google.com by
DenisBon...@gmail.com
on 5 Jul 2010 at 10:09