valor-software / ngx-bootstrap

Fast and reliable Bootstrap widgets in Angular (supports Ivy engine)
https://valor-software.com/ngx-bootstrap
MIT License
5.53k stars 1.69k forks source link

Changing one timepicker field resets validation for the others #5088

Open jonrimmer opened 5 years ago

jonrimmer commented 5 years ago

Bug description or feature request:

If you add an invalid value to a timepicker, the invalid value is highlighted in red in the UI. If you then change another field, the invalid field is reset.

Plunker/StackBlitz that reproduces the issue:

https://stackblitz.com/edit/timepicker-broken-validation?file=src%2Fapp%2Fapp.component.html

  1. Add an invalid value, e.g. "99" into the hours field.
  2. Confirm that the hours field is outlined red to indicate its invalid status.
  3. Add any value in the minutes field.
  4. Confirm that the hours field's red outline is removed.

Versions of ngx-bootstrap, Angular, and Bootstrap:

ngx-bootstrap: 3.3.0

Angular: 7.2.7

Bootstrap: 4

Build system: Angular CLI, System.js, webpack, starter seed:

Angular CLI

musou1500 commented 5 years ago

I propose put input values(hours, minutes, seconds) to store, and define a selector function that returns validities. so, validities will always sync with the latest input values.

this.validities$ = _store.select(selectValidities());
<ng-container *ngIf="validities$ | async as validities">
   <td class="form-group" [class.has-error]="validities.invalidHours">
     <input type="text" [class.is-invalid]="validities.invalidHours"
     ...

I think I can create PR if needed.