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

[DateRangePicker] Add maxRange prop #8868

Open
2 tasks done
TiagoPortfolio opened this issue May 4, 2023 · 1 comment
Open
2 tasks done

[DateRangePicker] Add maxRange prop #8868

TiagoPortfolio opened this issue May 4, 2023 · 1 comment
Labels
component: DateRangePicker The React component. component: pickers This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature plan: Pro Impact at least one Pro user

Comments

@TiagoPortfolio
Copy link
Contributor

TiagoPortfolio commented May 4, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Summary 💡

The DateRangePicker accepts the minDate and maxDate props but if you want to control these props based on the selected start or end dates, it can be difficult.
I think for the DateRangePicker component it would make sense to add a maxRange props which accepts the max range of days accepted.

Examples 🌈

For instance, if in the start date the user selects 04/05/2023 and the maxRange is 10, the DateRangePicker should only allow selecting an end date until 14/05/2023.
When the date picker is closed and opened again, the limits should be reset so the user can set a new date out of the current limits and the new limit should be calculated based on that new date.
Screenshot 2023-05-04 at 16 21 29
If I want to select a new date after the max limit defined based on the currently selected date, I can't because it is disabled. It is annoying that I have to clear the date, which causes the date picker to close again, open the date picker and select the new date freely.

Motivation 🔦

Allow a maxRange to avoid creating a fully controllable DateRangePicker to also control the minDate and maxDate props.

Order ID 💳 (optional)

54728

@TiagoPortfolio TiagoPortfolio added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 4, 2023
@alexfauquette alexfauquette added plan: Pro Impact at least one Pro user component: pickers This is the name of the generic UI component, not the React module! component: DateRangePicker The React component. enhancement This is not a bug, nor a new feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 5, 2023
@alexfauquette
Copy link
Member

Sounds like a nice idea.

Since the date range validation might always depend on the current state, we could support callback for validation props, such that this issue could be solved by maxDate={currentValue => currentValue[0] === null ? null : currentValue[0].addDays(5)}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: DateRangePicker The React component. component: pickers This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature plan: Pro Impact at least one Pro user
Projects
None yet
Development

No branches or pull requests

3 participants