Fix #8052 year not updated with viewDate changes
Fix #8052 Fix #8258 The issue occurred when we set the view date and deleted the input field. The currentYear variable retained the old value (in this case, 2000).😶🌫️ https://github.com/primefaces/primereact/blob/d57bbb7e4f57371e133668b42db3dc1435191f10/components/lib/calendar/Calendar.js#L3391-L3393 I adjusted displayYear to use metaYear, which fixes the issue, and the yearNavigator works correctly. However, if we modify the value of InputRef.current.value in a way that it cannot be parsed as a Date, the rendering will fall back to using ViewDate as the parameter.😺
Thanks a lot for your contribution! But, PR does not seem to be linked to any issues. Please manually link to an issue or mention it in the description using #<issue_id>.
@ulgyd0gg unfortunately this fix for year just keeps going back and forth. See the list of tickets in the past for "year not updating" issues: https://github.com/primefaces/primereact/pulls?q=is%3Apr+year+is%3Aclosed
I think your fix is just putting it back how it was and fixed a couple of scenarios but breaks a few more.
Look at the Git Blame on those lines of code to see last ticket and fix
@melloware I thought about these during the changes. What’s the desired behavior—should currentValue become null if value is empty, defaulting to currentValue || metaYear? Or should we always use the last selected value? I’d like the core team’s input on this.
This is behavior after change. I set newDate() as viewDate
@ulgyd0gg i have fixed this back and forth over the years and i am not sure what the right solution is. I have fixed it for people to fix one scenario and then another bug gets reported. Ideally we would have a list of of all test cases and make sure they all work.