Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormControl triggers statusChanges/valueChanges continuously when minDate and maxDate are specified #76

Open
MBALDONCINI opened this issue May 12, 2022 · 0 comments

Comments

@MBALDONCINI
Copy link

If the timepicker component is used not in template driven forms mode (i.e. not with ngModel binding but with an input formControl), the formControl status changes are always triggered although the value does not change.
This happens only if the minDate and maxDate are specified.

In html template
<input [class.color-transparent]="dialogOpen == true && !originalValue" matInput placeholder="{{placeholder | translate}}" [formControl]="timeFormControl" (timeChange)="focusIn == false ? timeChangeHandler('timechange') : ''" (invalidInput)="onInvalid($event)" (focusin)="focusIn = true" (focusout)="focusIn = false; timeChangeHandler('focus')" #t="matTimepicker" matTimepicker mode="24h" okLabel="{{okLabel | translate}}" cancelLabel="{{cancelLabel | translate}}" [disableDialogOpenOnClick]="true" [minDate]="minDate" [maxDate]="maxDate" [required]="required" >

In ts
@input() timeFormControl: FormControl = new FormControl(null);

` ngOnInit() {
moment.locale(this.translate.currentLang);

this.timeFormControl.statusChanges.subscribe((status : any) => {
  console.log("status changes ", status);
})

}`
The same happens for the valueChanges observable

Would it also be possible to accept undefined minDate and maxDate?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant