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

Week Picker Skips Months When Decreasing Month from 1st day falling after Fridays #4581

Closed
heyitsashleyhere opened this issue Mar 11, 2024 · 4 comments · Fixed by #4601
Closed

Comments

@heyitsashleyhere
Copy link

heyitsashleyhere commented Mar 11, 2024

Describe the bug
When decreasing the month using the 'showWeekPicker' prop, it unexpectedly skips February when the current date is set to March 1st, 2024.

To Reproduce

  1. Visit the React Datepicker documentation where the WeekPicker demo is featured.
  2. Change the date from "2021/02/22" to "2024/03/01"
  3. Click on input to open the calendar
  4. Click on the '<' (left arrow) to decrease the month

Expected behavior
The calendar should display the month of February.

Desktop (please complete the following information):

  • OS: [iOS]
  • Browser [chrome]
  • Version [latest]

Additional context
This issue occurs in any month where the 1st day falls after Fridays (Fri-Sun)

@yuki0410-dev
Copy link
Contributor

I reproduced the same event on my end.

At the stage you selected 2024/03/01,
The selected is 2024/02/26, which is the beginning of the week 2024/03/01. The reason for this is that when you open the calendar in step 3, you will see February 2024.
If you execute step4 from that state, you will see January, one month back from February.
This seems to me to be a fine behavior.

@heyitsashleyhere
Copy link
Author

heyitsashleyhere commented Mar 11, 2024

Thank you for the clarification.
I realise now that my initial description may not have been entirely clear. And so I updated the description and my reply here:

When the startDate or selected date is already set, and we proceed to 'step 3', the expectation is to view February 2024. However, we encounter March 2024 instead, which could potentially lead to user confusion.

Furthermore, in cases where no date is pre-selected and the calendar defaults to displaying the current date, it seems counterintuitive for a month to be skipped entirely upon attempting to decrease the month. This behavior might not align with user expectations, particularly in scenarios without a pre-filled date. I hope this helps clarify the specific concerns encountered.

@heyitsashleyhere heyitsashleyhere changed the title Week Picker Skips February When Decreasing Month from March 1st Week Picker Skips Months When Decreasing Month from 1st day falling after Fridays Mar 12, 2024
@yuki0410-dev
Copy link
Contributor

yuki0410-dev commented Mar 12, 2024

Thank you for your comment.
I agree that it is a non-intuitive behavior, as I did not understand what happened when I first verified it.

How about the following policy for revision?

  • before
    • selected (startDate) : Keeps the first date of the week for the selected date.
  • after
    • selected (startDate) : Keeps the selected date

(I do not use English on a daily basis, so I am sory that my writing is not good.)

(@martijnrusschen)

@heyitsashleyhere
Copy link
Author

Ok, yeah that sounds like a good solution :)

yuki0410-dev added a commit to yuki0410-dev/react-datepicker that referenced this issue Mar 16, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…th showWeekPicker
yuki0410-dev added a commit to yuki0410-dev/react-datepicker that referenced this issue Mar 16, 2024
yuki0410-dev added a commit to yuki0410-dev/react-datepicker that referenced this issue Mar 16, 2024
yuki0410-dev added a commit to yuki0410-dev/react-datepicker that referenced this issue Mar 16, 2024
martijnrusschen added a commit that referenced this issue Mar 16, 2024
fix: #4581 and #4560 selected and preSelection  with showWeekPicker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants