react-native-calendars icon indicating copy to clipboard operation
react-native-calendars copied to clipboard

Regression on 1.1278.0, Calendar[OnDayPress]

Open VittoriDavide opened this issue 2 years ago • 15 comments

From version 1.1278.0, on Calendar the onDayPress is not returning the correct date for other months than current.

VittoriDavide avatar Mar 22 '22 07:03 VittoriDavide

@VittoriDavide Is this issue still relevant? Can you expand on it?

Inbal-Tish avatar Mar 28 '22 06:03 Inbal-Tish

@Inbal-Tish this is still a problem, listening to the onDayPress event with the Expandablecalendar component, but only when it is opened, returning the date but one month before. i'm using the 1.1280.0 version

msolanogithub avatar Apr 05 '22 16:04 msolanogithub

@Inbal-Tish same issue. Sometimes the onDayPress return the month before the selected. @VittoriDavide @msolanogithub is downgrade to older version fix this problem?

thp96 avatar Apr 06 '22 07:04 thp96

yes I downgraded to an older version to fix this problem

VittoriDavide avatar Apr 06 '22 07:04 VittoriDavide

@VittoriDavide @msolanogithub @thp96 Can someone add a code snippet? I'm having a hard time understanding which component and callbacks you're using so I can reproduce this bug.

Inbal-Tish avatar Apr 06 '22 09:04 Inbal-Tish

Hi @Inbal-Tish , I just render the CalendarList component and log the results from onDayPress, click on any date on the calendar and see the month is incorrect. Ex:

  • Expect: { day: 6, month: 4, year: 2022 }
  • Actual: { day: 6, month: 3, year: 2022 }

thp96 avatar Apr 06 '22 11:04 thp96

@Inbal-Tish here is a snack https://snack.expo.dev/@michael_solano/wix-calendar. Looks like the issue is when the prop date of CalendarPriver is not the current date

msolanogithub avatar Apr 06 '22 17:04 msolanogithub

@msolanogithub Hey. I'm playing with your code in the snack.expo and in our demo app and I don't see what's not working... see my videos. Maybe I don't understand the issue... Also important, you should NOT connect CalendarProvider's date prop to the state. It is unnecessary and can cause redundant renders.

https://user-images.githubusercontent.com/33805983/162130929-11ed849b-bfc2-4966-b019-c2ae1a8f68b1.mov

https://user-images.githubusercontent.com/33805983/162130938-05bf02f3-7371-42be-8e14-919b68917315.mov

Inbal-Tish avatar Apr 07 '22 06:04 Inbal-Tish

@Inbal-Tish you are right, with the preview of snack exp it didn't happen, I'm testing with a simulator in IOS 15.2 and iPhone 11 and thanks for the date prop and the state

https://user-images.githubusercontent.com/38920570/162216895-e5f11e97-a7e5-4d15-802b-9aca62c6f414.mov

msolanogithub avatar Apr 07 '22 14:04 msolanogithub

For example I was doing like this:

import { Calendar } from 'react-native-calendars';
 <Calendar
        markingType="period"
        theme={calendarTheme}
        onDayPress={setDay}
        markedDates={periodDay}
        current={new Date()}
        maxDate={new Date()}
        renderArrow={(direction) => {
          if (direction === 'left') {
            return <ArrowLeft />;
          }
          return <ArrowRight />;
        }}
      />

and here the objDay contained the wrong data:

 const setDay = (objDay) => {
    const {
      dateString,
    } = objDay;

I don't think it'll matter but I was using "expo": "^43.0.0"

VittoriDavide avatar Apr 08 '22 07:04 VittoriDavide

I was trying to find the bug, maybe here https://github.com/wix/react-native-calendars/commit/3827d8b208c1aa9911d7c5e577316c5c64e91716

VittoriDavide avatar Apr 08 '22 07:04 VittoriDavide

@Inbal-Tish you are right, with the preview of snack exp it didn't happen, I'm testing with a simulator in IOS 15.2 and iPhone 11 and thanks for the date prop and the state

Screen.Recording.2022-04-07.at.8.43.28.AM.mov

This is exactly what happened in my project!

thp96 avatar Apr 21 '22 02:04 thp96

Does everyone are using expo to reproduce the bug?

@VittoriDavide I tried your code in our demo app and I don't see the issue. When I console objDay I get the correct day.

Inbal-Tish avatar May 25 '22 11:05 Inbal-Tish

Well actually I was using expo, on iOS simulator

VittoriDavide avatar Jun 06 '22 17:06 VittoriDavide

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[bot] avatar Sep 08 '22 16:09 stale[bot]