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

Calendar: viewDate change does not update displayed year #4147

Closed
mpressmar opened this issue Mar 9, 2023 · 2 comments · Fixed by #5539
Closed

Calendar: viewDate change does not update displayed year #4147

mpressmar opened this issue Mar 9, 2023 · 2 comments · Fixed by #5539
Assignees
Labels
Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@mpressmar
Copy link
Contributor

mpressmar commented Mar 9, 2023

Describe the bug

When changing the property viewDate of a Calendar component after the initial rendering, and the new viewDate has a different year than the previously viewed date, the Calendar will show the year incorrectly.

Reproducer

https://codesandbox.io/s/primereact-test-forked-zr0qtm?file=/src/index.js

PrimeReact version

9.2.0

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

Steps to reproduce in linked codesandbox:

  1. Open the calendar by clicking in the input field. The current date will be displayed (March 2023 as of time of writing).
  2. Click on the p-Text which sets the viewDate property to February 2021.
  3. Open the calendar again by clicking in the input field. The calendar shows February 2023 (current year) in the header. When selecting a date, or when using the month navigator, the correct year (2021) is displayed/selected.

Expected behavior

The year set in viewDate should be displayed by the Calendar.

@mpressmar mpressmar added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Mar 9, 2023
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Mar 9, 2023
@melloware
Copy link
Member

Workaround: https://codesandbox.io/s/primereact-test-forked-ebvk2b

call onClick={() => ref.current.updateViewDate(null, new Date(2021, 1, 1))} works.

@melloware melloware added the Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team label Mar 9, 2023
@mpressmar
Copy link
Contributor Author

@melloware Thanks for the workaround- that works for us!

@melloware melloware self-assigned this Dec 6, 2023
@melloware melloware added this to the 10.2.2 milestone Dec 6, 2023
melloware added a commit to melloware/primereact that referenced this issue Jan 9, 2024
melloware added a commit that referenced this issue Jan 9, 2024
* Fix #5349: PanelMenu fix from PrimeVue

* Fix #5360: Cascade select popup not closing on escape

* fix: #5363, Mention: Page Breaks when navigating to Mention component

* fix: #5365 SplitButton popup not closing on escape button click

* Fix #5367: SpeedDial close on escape

* Fix #2666: Fix overlay components in cell editor

* Fix #5363: Mention better fix

* Fix #5379: Accordion tab header passthrough errors
Fix #5546: AccordionTab Tailwind issues

* Fix #5385: Password inputClassname missing

* Fix #5390: Calendar only render navigator in first month of multiple months

* Fix #5202: Calendar rendering performance increase

* Fix #5535: Calendar update input on locale change

* Fix #5533/#4147: Calendar respect viewDate

* Fix Calendar Input Docs

* fix:Calendar:currentView changed should invoke alignOverlay

* Fix #5379: Accordion tab header passthrough errors
Fix #5546: AccordionTab Tailwind issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants