Skip to content

Commit fcb72a3

Browse files
committed
SVYX-899 Entering a date manually into the calendar, ignores the min/max
set and doesnt call the onDataChange function to validate it. - update
1 parent 1e69029 commit fcb72a3

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

projects/bootstrapcomponents/src/calendar/calendar.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DOCUMENT } from '@angular/common';
22
import { Component, Renderer2, ElementRef, ViewChild, Input, ChangeDetectorRef, SimpleChanges, ChangeDetectionStrategy, Inject, HostListener } from '@angular/core';
33
import { DateTime, Namespace, TempusDominus } from '@eonasdan/tempus-dominus';
4-
import { Format, FormattingService } from '@servoy/public';
4+
import { FormatDirective, Format, FormattingService } from '@servoy/public';
55
import { LoggerFactory, ServoyPublicService } from '@servoy/public';
66
import { ServoyBootstrapBaseCalendar } from './basecalendar';
77

@@ -13,6 +13,8 @@ import { ServoyBootstrapBaseCalendar } from './basecalendar';
1313
export class ServoyBootstrapCalendar extends ServoyBootstrapBaseCalendar {
1414

1515
@ViewChild('inputElement') inputElementRef: ElementRef;
16+
17+
@ViewChild(FormatDirective) svyFormat: FormatDirective;
1618

1719
@Input() format: Format;
1820
@Input() pickerOnly: boolean;
@@ -150,6 +152,11 @@ export class ServoyBootstrapCalendar extends ServoyBootstrapBaseCalendar {
150152
this.dataProviderID = event;
151153
super.pushUpdate();
152154
}
155+
156+
if (event !== '' && ((this.minDate && this.minDate > event) || (this.maxDate && this.maxDate < event))) {
157+
// revert to old value
158+
this.svyFormat.writeValue(this.dataProviderID);
159+
}
153160
}
154161

155162
public getNativeChild(): any {

0 commit comments

Comments
 (0)