Skip to content

Commit 5306367

Browse files
dobromirtsLipatakdinev
authored
fix(date-time-editor): handle iso date string for mask value -17.1.x (#14071)
Co-authored-by: Nikolay Alipiev <[email protected]> Co-authored-by: Konstantin Dinev <[email protected]>
1 parent a758016 commit 5306367

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

projects/igniteui-angular/src/lib/directives/date-time-editor/date-time-editor.directive.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,20 @@ describe('IgxDateTimeEditor', () => {
383383
fixture.detectChanges();
384384
expect(fixture.componentInstance.dateEditor.elementRef.nativeElement.value).toEqual('09/11/2009');
385385
});
386+
387+
it('should update value and mask according to the display format and ISO string date as value', () => {
388+
fixture.componentInstance.dateTimeFormat = 'dd/MM/yy';
389+
fixture.componentInstance.displayFormat = 'shortDate';
390+
dateTimeEditorDirective.value = new Date(2003, 3, 5).toISOString();
391+
fixture.detectChanges();
392+
inputElement.triggerEventHandler('focus', {});
393+
fixture.detectChanges();
394+
expect(dateTimeEditorDirective.mask).toEqual('00/00/00');
395+
expect(inputElement.nativeElement.value).toEqual('05/04/03');
396+
UIInteractions.simulateTyping('1', inputElement);
397+
expect(inputElement.nativeElement.value).toEqual('15/04/03');
398+
});
399+
386400
it('should correctly display input format during user input', () => {
387401
fixture.componentInstance.dateTimeFormat = 'dd/MM/yy';
388402
fixture.detectChanges();

projects/igniteui-angular/src/lib/directives/date-time-editor/date-time-editor.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ export class IgxDateTimeEditorDirective extends IgxMaskDirective implements OnCh
552552

553553
private getMaskedValue(): string {
554554
let mask = this.emptyMask;
555-
if (DateTimeUtil.isValidDate(this.value)) {
555+
if (DateTimeUtil.isValidDate(this.value) || DateTimeUtil.parseIsoDate(this.value)) {
556556
for (const part of this._inputDateParts) {
557557
if (part.type === DatePart.Literal) {
558558
continue;

0 commit comments

Comments
 (0)