-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Describe the bug
After the 4.4.0 release an issue started occurring when Datepicker is used with inline rendering. I have a page with 3 datepickers - 2 as input for start and end date and 1 as inline. They are interconnected through 3 state variables and watchers to keep them in sync.
I could also apply values to those state variables with outside methods and the components reacted properly until version 4.4.0 where it seems that the internal metadata calculation for the currentMonth, currentYear etc. happens before the rawValue(added in 4.4.0) is set. Therefore every update to the Datepicker calculates the previous state metadata because the updateCurrentMetaData call happens beforehand as per this commit b001959
I have prepared stackblitz with 4.4.1 which is current version. I personally spent time reading the entire refactoring that uses the new rawValue but I can't understand why is the call on line 631 in DatePicker.vue modelValue watcher here https://github.com/primefaces/primevue/blob/master/packages/primevue/src/datepicker/DatePicker.vue happening before the rawValue is set - shouldn't it be the opposite?
In the 4.4.1 stackblitz I added 2 lines that are commented out and if you uncomment them you will make it work. What these lines do is pretty much manually set the rawValue so the correct metadata is calculated, but that does not happen through the API and it's a bad pattern.
4.4.1
https://stackblitz.com/edit/7elhhhrr?file=src%2FApp.vue
Am I using the component incorrectly based on the latest updates or this is an actual bug?
Pull Request Link
No response
Reason for not contributing a PR
- Lack of time
- Unsure how to implement the fix/feature
- Difficulty understanding the codebase
- Other
Other Reason
No response
Reproducer
https://stackblitz.com/edit/7elhhhrr?file=src%2FApp.vue
Environment
N/A
Vue version
3.5.22
PrimeVue version
4.4.1
Node version
No response
Browser(s)
All of them
Steps to reproduce the behavior
Using the provided stackblitz:
- Open the link
- Use one of the inputs above the write in a date in format dd/mm/yyyy/ that is outside of the currently visible months
- The DatePicker with inline mode does not move it's visible months immediately
- Write in the same date or any other date
- The DatePicker now moves but takes in the previously entered value and in case it's not the same the visualized months are still incorrect
Not using the provided stackblitz:
- Run the latest PrimeVue version and just use DatePicker with inline vue setting it's internal range value to something random (not on mount and not from the UI, but afterwards programatically) and observe the DatePicker UI.
Expected behavior
The correct visible months and years in the inline DatePicker should be immediately visible on any value change.