angular / angular/components

feat(MatDatePicker): DateRange should implement min/max duration

Open
#20,780 3 comments 5 reactions 0 assignees View on GitHub
area: material/datepicker feature P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

#### Feature Description

I would like to use date picker to allow a user to pick any number of days from 1-7, but no more than 7.

This could be implemented by adding a minimum (default: 1) and maximum (default: unlimited) duration values to the DateRange type.

If the minimum duration is not default:
- create greyed-out preview overlay of end values less than the minimum duration but not before the start value. Selecting a value within the minimum duration or before the start date should reset the start date to new date.

If the maximum duration is not default:
- create a preview up to the maximum duration. Selecting value beyond the maximum duration becomes new start date.

Example with (min 3 days, max 7 days) might look like something this:

(this is only to illustrate, I'm not a UI designer or anything)

#### Use Case

Currently, I must have the user use a dropdown to pick their duration first (which informs a MatDateRangeSelectionStrategy), and then use the date picker to select a start date.

Would very much like to get rid of the dropdown.

Contributor guide

Open the contributing guide

Research direction

Start by reading the MatDatePicker date-range behavior and MatDateRangeSelectionStrategy described in the issue. Define and verify minimum and maximum duration behavior, including the preview overlays and resetting the start date when a selection falls outside the allowed range.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.