nebular icon indicating copy to clipboard operation
nebular copied to clipboard

Date-TimePicker adding errors to FormControl despite date being correct

Open RikiGomes opened this issue 3 years ago • 1 comments

Issue type

I'm submitting a ...

  • [x] bug report
  • [ ] feature request

Issue description

Current behavior: When selecting a Date on a form, the Date-TimePicker Component is setting the form as invalid by adding values to the error array. Screenshot 2022-03-22 at 20 40 39

Expected behavior: The FormControl errors array should not have any values and formControl.valid should return true

Steps to reproduce: Pick a date and see output from printErrors on console

Related code: HTML

<input nbInput [nbDatepicker]="wdd"
                           formControlName="WishedDeliveryDate" fieldSize="small" fullWidth
                           [status]="form.controls['WishedDeliveryDate'].errors?.invalidDate ? 'danger' : 'basic'" (ngModelChange)="printErrors()">
                    <nb-date-timepicker #wdd singleColumn [step]="15" [min]="minDateForPicker"></nb-date-timepicker>

Typescript

  // setting formControl inside formGroup
  WishedDeliveryDate: [this.order.WishedDeliveryDate != null ? new Date(this.order.WishedDeliveryDate) : '', [invalidDateValidator()]],

  // print errors
  printErrors(){
    console.log('-------------------')
    console.log(this.form.controls['WishedDeliveryDate'].errors)
    console.log('-------------------')
  }

invalidDateValidator does not set either of those errors. (setting a error like { invalidDate:true } )

Other information:

npm, node, OS, Browser

Node; npm: v14.17.5; 8.3.0
OS: Windows 10 AND MacOS
Browser: All (Safari, Chrome, Edge, Firefox tested)

Angular, Nebular

Angular: 13.2.0
Nebular: 9.0.0

RikiGomes avatar Mar 22 '22 20:03 RikiGomes

Note: I've tried with either NbDateFnsDateModule active and not active.

RikiGomes avatar Mar 22 '22 20:03 RikiGomes