Auto clear value DateTimePicker if inserted date is incomplete

0 Answers 8 Views
DateTimePicker
Andrii
Top achievements
Rank 1
Andrii asked on 25 Apr 2024, 04:09 PM | edited on 26 Apr 2024, 08:30 AM

 

Hi.

I'm trying to clear data in a control if the user has entered an incomplete date. My ControlValueAccessor, which wraps a DateTimePicker, implements the following logic.
If the control contains a {incompleteDate: true} error and the input field loses focus, patchValue(null) is executed. However, the control still contains the error {incompleteDate: true}

 

I think not correct check in this line (libs/dateinputs/src/dateinput/dateinput.component.ts)

this.isDateIncomplete = this.kendoDateObject.hasValue() && this.value === null;

full method

    private updateIncompleteValidationStatus(): void {
        const previousValue = this.isDateIncomplete;
        this.isDateIncomplete = this.kendoDateObject.hasValue() && this.value === null;  // Not correct check

        if (previousValue === this.isDateIncomplete || !this.incompleteDateValidation) { return; }

        if (isPresent(this.ngControl) && !isPresent(this.pickerService)) {
            this.cdr.markForCheck();
            this.ngZone.run(() => this.onValidatorChange());
        } else if (isPresent(this.pickerService)) {
            this.pickerService.dateCompletenessChange.emit();
        }
    }

Installed packages

"@progress/kendo-angular-dateinputs": "15.4.0",
"@angular/core": "^16.2.12",
 

Live demo

https://stackblitz.com/edit/angular-czvcsm-zrtsrw?file=src%2Fapp%2Fdate-picker%2Fdate-picker.component.html

Thanks for help.

 

No answers yet. Maybe you can help?

Tags
DateTimePicker
Asked by
Andrii
Top achievements
Rank 1
Share this question
or