components icon indicating copy to clipboard operation
components copied to clipboard

feat(DatePicker): select range of dates

Open alaawerfelli opened this issue 9 years ago • 148 comments

Hello, it's possible to set date range in date picker (have the ability to choose startDate and endDate and get all dates between startDate and endDate).

alaawerfelli avatar May 24 '17 08:05 alaawerfelli

It is being worked on (you can see the date-range branch). It's still missing a couple of features like comparison ranges, but we're on track to have it done by the end of March.

Thanks for the update

guyng avatar Mar 05 '20 09:03 guyng

Many thanks to all involved on this feature. Really excited to use it!

diogoterremoto avatar Mar 05 '20 09:03 diogoterremoto

I wonder if it would be possible to use the date-range picker to set open ranges. Like 2020.03.05. - null; null - 2020.03.05. Cause that would be nice and handy.

Totati avatar Mar 05 '20 10:03 Totati

I am super excited for this feature! Thank you for working on it!

anbiniyar avatar Mar 19 '20 13:03 anbiniyar

We're also eagerly waiting for this feature! Is there a page with a demo of the current version so that we can provide feedback before it goes live?

clement911 avatar Mar 19 '20 14:03 clement911

@clement911 not yet, you can try the branch out though (see https://github.com/angular/components/issues/4763#issuecomment-595116421).

Splaktar avatar Mar 20 '20 20:03 Splaktar

@Splaktar how do we 'try out' a branch?

clement911 avatar Mar 21 '20 09:03 clement911

@clement911 https://github.com/angular/components/blob/master/DEV_ENVIRONMENT.md#developer-guide-getting-your-environment-set-up. Then in the dev-app, you can check out the datepicker demo.

Splaktar avatar Mar 21 '20 20:03 Splaktar

Thanks @Splaktar but honestly I just wish there would be a simpler way, like a demo that we can play with to provide some feedback on the component UX.

Will we be able to play with the date range on https://next.material.angular.io/components/datepicker ?

clement911 avatar Mar 23 '20 13:03 clement911

@clement911 something like that will be made available in the future.

Splaktar avatar Mar 23 '20 14:03 Splaktar

excited!

demiro avatar Mar 23 '20 17:03 demiro

I am very excited for this, are there any updates ?

mfarahat avatar Mar 24 '20 21:03 mfarahat

You can see the demo of the in-progress work here: https://jelbourn-dev.firebaseapp.com/datepicker

FYI after starting we, we got some feedback that led to expanding the scope of the initial work to make sure we'll be able to eventually support touch selection, comparison ranges, and customizable range selection.

jelbourn avatar Mar 27 '20 18:03 jelbourn

great.... would be also good example to see option with 2 months open the the same time when selecting a range (check most of the airlines... ryanair.com or avianca.com or united airlines or turkish airlines) this would be the most ux friendly...

also, one very UX feature would be in the input mask, when clicking on a date, to have a whole date selected .... so if I am editing 1st date in the range... and click on the second (and it was already in) to select the whole date (regardles of which part of the date I click) and obviously let me edit from the left onward...

and, maybe give a setting option, to have date part selected on the first click

meaning, if I want to change a year of the second date, now I would have to click on that year, and then double click again to select all numbers and then start typing to override it... instead of clicking a year to be selected and start typing, or click to select all and click again to edit normally desired digit...

I appreciate might not be desired functionality for all, but would be a nice feature to have and be able to configure it easily

demiro avatar Mar 28 '20 05:03 demiro

It looks pretty great!

But I don't understand why March 9th o March 13th shows in a different color?

image

great.... would be also good example to see option with 2 months open the the same time when selecting a range (check most of the airlines... ryanair.com or avianca.com or united airlines or turkish airlines) this would be the most ux friendly...

We would also very much like this option. Our current calendar actually shows 2 months already because it's very common to select a date range that span across 2 consecutive months.

clement911 avatar Mar 28 '20 07:03 clement911

I'm assuming the input mask will be customizable / localizable ? e.g., mm/dd/yyyy or dd/mm/yyyy?

Also the first day of the week could be different depending on locale, is that supported? (sorry if it is already, I haven't used the existing calendar component)

clement911 avatar Mar 28 '20 07:03 clement911

Sometimes the range needs to be set to only one day (from/to same day). This is not possible in the provided demo.

perchristian avatar Mar 30 '20 07:03 perchristian

First, let me just say that with a UI as complex as a date range picker, there are a ton of features and possible UIs, but unfortunately we can't do them all.

Specifically to answer some of the questions above:

@demiro

  1. There are no plans to add a 2 calendar side-by-side view, though we do intend to allow the <mat-calendar> to be used as a standalone component so that users can build their own side-by-side experience. We do intend to add the ability to scroll through months, but not in the first release.
  2. The two ends of the range are completely separate <input> elements, so adding a feature to select the whole range would be quite complicated. This is not something we plan to do.

@clement911

  1. The different color dates are what we call a "comparison" range. Its an extra feature we threw in because it was requested by a number of Google teams, but showing a comparison range is optional, so it can be left out if you don't need it.
  2. Localization will work the same as the normal datepicker, the only localization feature added specifically for the range picker is that the divider character in the input can be customized

@perchristian That's a good point, let me run that one by our UX folks

mmalerba avatar Mar 30 '20 17:03 mmalerba

Got it, thanks for these explanations.

Sometimes the range needs to be set to only one day (from/to same day)

I really hope that you fixed that one otherwise we just wouldn't be able to use this component.

clement911 avatar Mar 31 '20 06:03 clement911

The arrow icons for previous/next months are lacking hover state.

perchristian avatar Mar 31 '20 08:03 perchristian