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

feat(datepicker): autoAdvanceCalendar - advance multimonth on select #2656

Conversation

foodforarabbit
Copy link
Contributor

Fixes #2471

Description

Added option

autoAdvanceCalendar?: boolean (default: true)

This option controls whether to shift months so that the first selected date appears in the first month (more relevant in multi-month calendar views)

Added yard config for option
Fixed autoFocusCalendar yard type (duplicates #2654)

Scope

  • Patch: Bug Fix
  • Minor: New Feature
  • Major: Breaking Change

@vercel
Copy link

vercel bot commented Jan 18, 2020

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/uber-ui-platform/baseweb/3vt6gmxtf
✅ Preview: https://baseweb-git-fork-foodforarabbit-datepicker-autoadvancecalendar.uber-ui-platform.now.sh

@tajo
Copy link
Member

tajo commented Jan 21, 2020

Nice feature!

  1. Could you please add it to the TypeScript defs?
  2. It would be great to have some test.

this.setState({
date: this.getDateInView(),
});
if (this.props.autoAdvanceCalendar) {
Copy link
Contributor

@nadiia nadiia Jan 21, 2020

Choose a reason for hiding this comment

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

This condition here will prevent displaying the currently selected date when date typed in and autoAdvanceCalendar set to false only to fix the shift in a multi-month view.
I don't think in the current implementation adding autoAdvanceCalendar should be used as a fix for the #2471. I'm thinking we should add something like isInView check for an updated value.
As for the autoAdvanceCalendar independently from the bugfix, could you provide an example when would we want to have the opened calendar show a different that selected date value on open? Also what would be that different date?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm the way I imagined the feature, the two modes of calendar would be

a) calendar view / months visible is "automatically" adjusted after it is open. The logic for adjusting the months is a separate issue (e.g. actually, we can do isInView check to fix #2471 it is still "automatically" adjusting the months if somehow the selected date was not visible)
b) calendar view / months visible is set automatically when opening the datepicker / popover, but after it is open, it is entirely manually controlled regardless of what else happens.

You are correct though, this is not really a direct solution for #2471 - more like I gave an alternate solution to prevent automatic control

Of course, we might still want to add isInView check so that calendar can have default autoAdvanceCalendar behaviour (i.e. original behaviour with view updating based on input value) but also not change views in multi-month when days are selected by clicking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh one more thought, is having the months advance in multi-month calendar a desired feature? Do we need another prop to switch between just the issue of months changing in multi-month mode (i.e. advance if not isInView feature)?

Please let me know what the best way to organize these features is!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think shifting calendar when a date is selected in a multi-month view creates not good user experience and we should just fix the shifting bug with something like isInView approach, I don't think it's something that should be customizable.
I can see where the very last day of the last visible month is selected and the shift would probably save an additional click to show later dates. But after checking a few popular services with calendars (non does that shift) and considering the second date in a range can be selected before or after the first selected date in our calendar implementation we should avoid that shift issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok that sounds reasonable, I will open up new PR with just that feature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fyi: #2672

@nadiia
Copy link
Contributor

nadiia commented Feb 5, 2020

Closing this one in favor of #2672

@nadiia nadiia closed this Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DatePicker] date select on right calendar shifts to left
5 participants