Skip to content

Datetimepicker validation issue if not required #351

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

Closed
JBBianchi opened this issue Oct 14, 2024 · 1 comment
Closed

Datetimepicker validation issue if not required #351

JBBianchi opened this issue Oct 14, 2024 · 1 comment
Labels
area: datetimepicker Issues about datetimepicker invalid This doesn't seem right

Comments

@JBBianchi
Copy link

Hello,

I found a strange behavior (in v17 at least, I didn't try in v18):

When binding a non required form control's input with the mtx-datetimepicke control, it looks like the related form's validity is messed up with.

After the first render, the form is invalid even though the target value is not required.

Filling the input with any value and then removing the value makes the form valid again.

I would expect the form to be valid right from the start.

See this StackBlitz sample

@nzbin nzbin added invalid This doesn't seem right area: datetimepicker Issues about datetimepicker labels Oct 15, 2024
@nzbin
Copy link
Member

nzbin commented Oct 15, 2024

Please use other adapter instead of native adapter #141

If you use native adapter, please set default value null

form = this.fb.group({
  dueDate: [null],
});

https://stackblitz.com/edit/nk9byo-uy4zgu?file=src%2Fexample%2Fdatepicker-overview-example.ts

@nzbin nzbin closed this as completed Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: datetimepicker Issues about datetimepicker invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants