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: Selection Month DropDown Item at Index 1 for the first time, Selects Item at Index 2 #2948

Closed
HarshilGandhi90 opened this issue May 31, 2022 · 5 comments · Fixed by #2950
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@HarshilGandhi90
Copy link

HarshilGandhi90 commented May 31, 2022

Describe the bug

Hey There, I am facing one issue in latest installed versions.

The issue is that I have used Calendar control which has Month and Year Dropdowns.

In Month Dropdown, I have Values from January till December

The problem is that For the First Click in this dropdown, If I select February(at Index 1), It selects March(at Index 2).

This Problem is only faced for the first click.

Please Resolve this in Some Older Versions also!

Please resolve this ASAP!

Reproducer

No response

PrimeReact version

8.1.1

React version

17.x

Language

ALL

Build / Runtime

Create React App (CRA)

Browser(s)

Chrome 101.0.4951

Steps to reproduce the behavior

  1. Click February which is at index 1 in Month Dropdown.
  2. Clicking February, Selects March for the first time.
  3. Again click February works fine.

Expected behavior

  1. Click February which is at index 1 in Month Dropdown.
  2. Clicking February, should Select February for all the times.
@HarshilGandhi90 HarshilGandhi90 added the Type: Bug Issue contains a defect related to a specific component. label May 31, 2022
@melloware melloware changed the title PrimeReact Calendar -> Selection Month DropDown Item at Index 1 for the first time, Selects Item at Index 2 Calendar: Selection Month DropDown Item at Index 1 for the first time, Selects Item at Index 2 May 31, 2022
@melloware
Copy link
Member

Confirmed using the Showcase: https://primefaces.org/primereact/calendar/

@HarshilGandhi90
Copy link
Author

I am still Facing the same issue! I have manually changed in Calendar.js file

@melloware
Copy link
Member

melloware commented May 31, 2022

I can't reproduce with my fix. So the issue is today is May 31st. So when it gets that date its setting Month to 1 making it "Feb 31st" of which there is no such thing so it makes it "March 03". My fix sets the view date to the first of the month every time so May 31st becomes May 01 then sets the month to Feb 01.

@HarshilGandhi90
Copy link
Author

Thank you @melloware for the Fix! I have verified it and working fine for me too!

@melloware
Copy link
Member

Excellent! Thanks for reporting and tested. I guess we were bound to run into this scenario eventually where the day was between 28-31st of hte month and someone tried to switch to February!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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