Skip to content

Commit

Permalink
fix(igDatePicker): Update to datepicker sync to handle text dataMode
Browse files Browse the repository at this point in the history
related changes: #1453
  • Loading branch information
damyanpetev committed Jun 6, 2018
1 parent ce73475 commit 97611e0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/js/modules/infragistics.ui.editors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10875,14 +10875,18 @@
_listMouseDownHandler: function () { // igDatePicker
},
_updateDropdownSelection: function () { //igDatePicker
var pickerInst, cursorPosition,
var pickerInst, cursorPosition, parsedDate,
val = this._editorInput.val();

// D.P. 19th Dec 2017 #1453 Update the `datepicker` selection if the input mask if fulfilled
if (this._pickerOpen && this._validateRequiredPrompts(val)) {
cursorPosition = this._getCursorPosition();
pickerInst = $.data( this._editorInput[ 0 ], "datepicker" );
this._editorInput.datepicker("setDate", this._valueFromText(val));
parsedDate = this._parseDateFromMaskedValue(val);
if (this.options.displayTimeOffset !== null) {
parsedDate = this._getDateOffset(parsedDate);
}
this._editorInput.datepicker("setDate", parsedDate);

// restore input after picker updates input:
this._editorInput.val(val);
Expand Down
39 changes: 39 additions & 0 deletions tests/unit/editors/DatePickerBugs/tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,45 @@
});
});

testId = "Issue 1453 pt2 - Enter date w/ format and displayModeText dataMode";
test(testId, function (assert) {
assert.expect(5);
var done = assert.async(),
today = target = new Date(),
targetString, targetKeys, tomorrow = true,
todayString = getDDmmYYYY(today, "-"),
$editor = $('<input/>').appendTo("#qunit-fixture2").igDatePicker({
dateInputFormat: "dd-MM-yyyy",
dataMode: "displayModeText"
}),
$calendar = $editor.igDatePicker("getCalendar");

targetKeys = todayString.replace(/-/g, "");

$editor.igDatePicker("field").focus();
$editor.igDatePicker("showDropDown");

$.ig.TestUtil.wait(400).then(function () {
// picker opens with today as default
strictEqual($calendar.find(".ui-datepicker-current-day").length, 0, "Calendar should have no initial selection");
//type in the date +/- a day, control check what's typed:
$.ig.TestUtil.type(targetKeys, $editor.igDatePicker("field"));
equal($editor.igDatePicker("field").val(), todayString, "Typed text should match");
equal($calendar.find(".ui-datepicker-current-day").text(), target.getDate(), "Calendar selection should be updated with typed in date");

$.ig.TestUtil.keyInteraction(13, $editor.igDatePicker("field"));
equal($editor.igDatePicker("field").val(), todayString, "Typed text should remain after enter");
equal($editor.igDatePicker("value"), todayString, "Value should match typed selection");

done();
}).catch(function (er) {
assert.pushResult({ result: false, message: er.message });
done();
throw er;
});
});


testId = "Issue 1733 - igDatePicker throws error, when selecting with displayModeText dataMode";
test(testId, function (assert) {
assert.expect(4);
Expand Down

0 comments on commit 97611e0

Please sign in to comment.