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

ArrowRight not scrolling to the right month when date day is 31 #1496

Closed
anthoninCL opened this issue May 7, 2021 · 2 comments
Closed

ArrowRight not scrolling to the right month when date day is 31 #1496

anthoninCL opened this issue May 7, 2021 · 2 comments
Labels

Comments

@anthoninCL
Copy link

Description

When the date day is 31 (for example 2021-05-31), if you click on the arrow right in order to swipe to next month, it's going to skip every month having less than 31 days.

Expected Behavior

Being the 2021-05-31 and clicking on the arrow right, I want to see the next month, being June.

Observed Behavior

Being the 2021-05-31 and clicking on the arrow right, it is showing me July.

Environment

Please run these commands in the project folder and fill in their results:

Also specify:

  1. Phone/emulator/simulator & version: I made this test on a Samsung Galaxy A70 with the new Android 11.

Reproducible Demo

I can't show a demo because this is for profesional purpose... I found a quick fix for now, by changing some lines in the node_modules/react-native-calendars/src/calendar-list/item.js by just cloning the month, adding one to it and scrolling to it.

@pqminh
Copy link

pqminh commented May 31, 2021

XDate addMonths was wrong!

XDate('2021-05-31', true)
.addMonths(1)
.toISOString() => XDate 2021-07-01T00:00:00Z

This work for me

onPressArrowRight={(_, month) => {
        try {
          let currentMonth = month.toDate();
          let nextMonth = moment(currentMonth)
            .add(1, 'month')
            .format('YYYY-MM-DD');
          currentMonth = XDate(nextMonth, true);
          calendarRef?.current?.scrollToMonth(nextMonth);
        } catch (error) {
          logd('error', error);
        }
      }}

arshaw/xdate#36

@stale
Copy link

stale bot commented Aug 29, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 29, 2021
@stale stale bot closed this as completed Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants