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 week view - pressing forwards/backwards buttons sometimes skips a week #144

Open
GuntisTreulands opened this issue Apr 30, 2021 · 0 comments

Comments

@GuntisTreulands
Copy link

Describe the bug
While implementing MBCalendarKit in my project and using a week view, I noticed a bug - where sometimes pressing next/previous buttons (to switch to forwards/backwards week), it sometimes skips a week.

To Reproduce
I could easily reproduce this problem using provided demo. In Objective-C Calendar Control -> week view and
Animated Week Transitions.

Steps to reproduce the behaviour skipping a week when pressing next button:

  1. Open a week view
  2. Click on the LAST date of the visible week (and notice the date)
  3. Press next button
  4. See that visibly a week has been skipped

Steps to reproduce the behaviour skipping a week when pressing previous button:

  1. Open a week view
  2. Click on the FIRST date of the visible week (and notice the date)
  3. Press previous button
  4. See that visibly a week has been skipped

The issue is not reproducable, if, before pressing any button - first/last date is not selected.

Expected behavior
I would expect a week not to be skipped.

Additional context
Tested on iPhone 7, iOS 12

Possible fixes
I found a possible solution that works for me.

For backward button, I added an extra code before this line:

date = [self.calendar dateBySubtractingWeeks:1 fromDate:date]; // Add a week

Code:
date = [self.calendar lastDayOfTheWeekUsingReferenceDate:date];
(Basically I set the date as the last day of the visible week, thus making sure that a week will not be skipped)

For forward button, I added an extra code before this line:

Code:
date = [self.calendar firstDayOfTheWeekUsingReferenceDate:date];
(Basically I set the date as the first day of the visible week, thus making sure that a week will not be skipped)

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

No branches or pull requests

1 participant