P-Calendar not invalidates set formControl, when date typed
[ x ] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Current behavior When using p-calendar connected to the formControl and passing it (by typing with keyboard) wrong formatted date (like string of 'abcd' or 31/11/2022) component automatically breaks showing NaN/NaN/NaN and do not respond to any other actions.
Expected behavior P-Calendar should be able to deal with formControl data in form of string or dates. In both cases if something wrong is with the data, it suppose to invalidate given control and set it suitable errors instead of showing NaN's.
Minimal reproduction of the problem with instructions
Into html insert component:
<p-calendar
[appendTo]="appendTo"
[dateFormat]="dateFormat"
[firstDayOfWeek]="1"
[formControl]="formControl"
[placeholder]="placeholder"
dataType="string"
[focusTrap]="false"
[selectOtherMonths]="true"
[showIcon]="true"
[showOnFocus]="showOnFocus">
</p-calendar>
where:
- formControl = new FormControl('',[])
- dateFormat = 'dd/mm/yy'
- placeholder = 'dd/mm/jjjj'
- appendTo = 'body'
- showOnFocus = true
And start typing some wrongly formated data, like abcd or 31/11/2022.
What is the motivation / use case for changing the behavior? Stopping doing custom validations on data we want to set on formControl, before giving it to p-calendar, cause it's not working well with formGroup validators.
-
Angular version: 12.2.15
-
PrimeNG version: 12.2.1
-
Browser: Chrome 97, but probably all.
-
Language: TypeScript 4.3.5
Hi,
Couldn't replicate the issue, could you please provide a Stackblitz example?
Regards
Hi,
So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you reopen the issue so we can include it in our roadmap? Please don't forget to add your feedback as a comment after reopening the issue. These will be taken into account by us and will contribute to the development of this feature. Thanks a lot for your understanding!
Best Regards,