Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit f4839af

Browse files
devversionjelbourn
authored andcommitted
fix(datepicker): set datepicker touched if bluring input or closing the pane
Fixes #6598 Closes #6722
1 parent 474c37a commit f4839af

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/components/datepicker/datePicker.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,8 @@
576576
this.calendarPaneOpenedFrom = null;
577577
this.$mdUtil.enableScrolling();
578578

579+
this.ngModelCtrl.$setTouched();
580+
579581
this.documentElement.off('click touchstart', this.bodyClickHandler);
580582
window.removeEventListener('resize', this.windowResizeHandler);
581583
}
@@ -600,6 +602,9 @@
600602
* @param {boolean} isFocused
601603
*/
602604
DatePickerCtrl.prototype.setFocused = function(isFocused) {
605+
if (!isFocused) {
606+
this.ngModelCtrl.$setTouched();
607+
}
603608
this.isFocused = isFocused;
604609
};
605610

src/components/datepicker/datePicker.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,28 @@ describe('md-date-picker', function() {
311311
expect(controller.ngModelCtrl.$modelValue).toEqual(initialDate);
312312
});
313313

314+
it('shoud become touched from bluring closing the pane', function() {
315+
populateInputElement('17/1/2015');
316+
317+
controller.openCalendarPane({
318+
target: controller.inputElement
319+
});
320+
controller.closeCalendarPane();
321+
322+
expect(controller.ngModelCtrl.$touched).toBe(true);
323+
});
324+
325+
it('should become touch from bluring the input', function() {
326+
populateInputElement('17/1/2015');
327+
328+
var input = angular.element(controller.inputElement);
329+
330+
input.triggerHandler('focus');
331+
input.triggerHandler('blur');
332+
333+
expect(controller.ngModelCtrl.$touched).toBe(true);
334+
});
335+
314336
it('should not update the input string is not "complete"', function() {
315337
var date = new Date(2015, DEC, 1);
316338
pageScope.myDate = date;

0 commit comments

Comments
 (0)