Skip to content

Fix #8052 year not updated with viewDate changes #8135

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ulgyd0gg
Copy link
Contributor

@ulgyd0gg ulgyd0gg commented Jul 12, 2025

Fix #8052
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).😶‍🌫️

const viewDate = getViewDate();
const viewYear = viewDate.getFullYear();
const displayYear = props.numberOfMonths > 1 || props.yearNavigator ? metaYear : currentYear;

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.😺

Copy link

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>.

@melloware
Copy link
Member

@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 melloware marked this pull request as draft July 12, 2025 12:45
@melloware melloware added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Jul 12, 2025
@ulgyd0gg
Copy link
Contributor Author

@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.

@ulgyd0gg
Copy link
Contributor Author

ulgyd0gg commented Jul 12, 2025

This is behavior after change. I set newDate() as viewDate
CalendarViewDate

@melloware
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calendar: year not updated with viewDate changes
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy