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

bug (ui): Fix Calendar Navigation #714

Closed
wants to merge 1 commit into from

Conversation

wrsulliv
Copy link

@wrsulliv wrsulliv commented Nov 3, 2019

Please read and mark the following check list before creating a pull request:

Short description of what this resolves:

Currently the left / right navigation buttons on the "Calendar" component do not update the Calendar header.

#713

Solution

I use the visibleDate state variable on baseCalendar instead of invoking the scrollToIndex function on calendarPager.

Problem

When calling the function directly, only the inner child of baseCalendar is updated: viewPager. This leaves the visibleDate state variable unchanged, which is what drives the header and other children of baseCalendar.

Next Steps

This may help resolve the left / right navigation problem, but there are at least two remaining problems:

  1. The header does not change properly at year boundaries.
  2. Swiping does not work as expected. This is because it's still only updating the internal component. To fix this, one idea is to pass a callback, enabling viewPager to inform its parents when it changes: Calendar UI Bug: Page Sliding - Invalid Header #712

…d "visibleDate". This helps prevent child state from going out of sync.
@artyorsh artyorsh self-requested a review November 3, 2019 09:05
@artyorsh artyorsh added 📱 Components components module-specific 🤷‍♂️ Needs info There is no enough info to resolve the issue labels Nov 3, 2019
Copy link
Collaborator

@artyorsh artyorsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thanks for reporting and opening a PR! 👍

When calling the function directly, only the inner child of baseCalendar is updated: viewPager.

Notice, the current implementation should work as expected since by pressing a button in the header, we call pager's scrollTo. Then, when the pager is finished scrolling, onDayPickerPagerSelect is called to update a visibleDate.

I tried to reproduce this bug in iOS, Chrome and Safari. I also tried to review live examples in the documentation and everything worked fine for me.

Running your code I noticed a small delay between the button click action and pager scrolling. Can share more details on this bug: Chrome / Safari version, user behavior?

@wrsulliv wrsulliv changed the title (UI Bug) (Calendar Component): Fix Invalid Header on Left / Right Navigation bug (ui): Fix Calendar Navigation Nov 3, 2019
@wrsulliv
Copy link
Author

wrsulliv commented Nov 3, 2019

Hi @artyorsh ! Thanks for the reply and the awesome package!

My apologies, I missed the callback in viewPager which updates baseCalendar .

However, I did some testing, and I believe this problem exists for users with a negative timezone offset. For example, I'm in Eastern Time (-4), so the min date calculated in baseCalendar is Dec. 2018 instead of Jan. 2019.

If you change your system time you should be able to reproduce the issue.

I can look into a PR for this if you'd like? My strategy would be to calculate all calendar dates in T+0, then add the user's timezone offset.

@artyorsh
Copy link
Collaborator

artyorsh commented Nov 3, 2019

@wrsulliv

I can look into a PR for this if you'd like? My strategy would be to calculate all calendar dates in T+0, then add the user's timezone offset.

Yes, let's create a new one if it could be a possible solution. Thanks for the explanation :)

@artyorsh artyorsh closed this Nov 13, 2019
@artyorsh artyorsh removed the 🤷‍♂️ Needs info There is no enough info to resolve the issue label Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📱 Components components module-specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants