Skip to content
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

fix(Calendar): apply viewDate Year when yearNavigator and view month mode #7503

Merged
merged 6 commits into from
Dec 14, 2024

Conversation

KumJungMin
Copy link
Contributor

Defect Fixes

How to resolve?

  • When a year is selected in yearNavigator mode, the onYearDropdownChange function is triggered.
  • The onYearDropdownChange function updates the viewDate state.
  • However, the onMonthSelect function uses currentYear, causing the updated viewDate to not be applied correctly.
  • To resolve this issue, I updated the onMonthSelect function as shown below:
const onMonthSelect = (event, month) => {
    if (props.view === 'month') {
        const year = props.yearNavigator ? getViewDate().getFullYear() : currentYear; // updated!
        onDateSelect(event, { year, month: month, day: 1, selectable: true });
    }
};

Test

When both YearNavigator and view="month" props are used together

Before
When both YearNavigator and view="month" props were used together, the selected year was being replaced with the current year when the calendar closed.
Additionally, clicking the previous and next buttons did not correctly reflect the viewYear.

2024-12-14.10.04.13.mov

After
the selected year is correctly applied when the calendar closes.
Furthermore, clicking the previous and next buttons accurately reflects the viewYear.

2024-12-14.10.02.19.mov

Copy link

vercel bot commented Dec 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Updated (UTC)
primereact ⬜️ Ignored (Inspect) Visit Preview Dec 14, 2024 1:20am
primereact-v9 ⬜️ Ignored (Inspect) Visit Preview Dec 14, 2024 1:20am

@melloware melloware merged commit 3bd25db into primefaces:master Dec 14, 2024
4 checks passed
@KumJungMin KumJungMin deleted the fix/issue-7496 branch December 15, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calendar: yearNavigator + view="month" doesn't work
2 participants