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

Calendar: shows future and/or past dates even when minDate and/or maxDate props are set #7649

Closed
acc-cassio opened this issue Jan 26, 2025 · 9 comments
Labels
Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior

Comments

@acc-cassio
Copy link
Contributor

Describe the bug

The Calendar component shows past and future dates even when minDate and maxDate are set.
Case in point: the "MinMax" example in the documentation. You can go past minDate and maxDate.

Apparently, this issue has been solved before, see issue #1661. However, the behaviour is still present in primereact's current version.

Reproducer

No response

System Information

PrimeReact version: 10.9.2

Steps to reproduce the behavior

  1. Go to https://primereact.org/calendar/#minmax
  2. Try to navigate to dates outside the min and max range
  3. Dates are displayed

Expected behavior

Dates before minDate and after maxDate (whichever is present, if any) should not be shown.

@acc-cassio acc-cassio added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 26, 2025
@melloware
Copy link
Member

There is a another property: https://primereact.org/calendar/#api.Calendar.props.showMinMaxRange

Some users wanted people to allow you to see older and future invalid dates but the showMinMaxRange property blocks you from going backwards or forwards.

@melloware melloware added Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jan 26, 2025
@melloware
Copy link
Member

Here is a stackblitz: https://stackblitz.com/edit/uvwu3ybx?file=src%2FApp.jsx

@melloware melloware closed this as not planned Won't fix, can't repro, duplicate, stale Jan 26, 2025
@acc-cassio
Copy link
Contributor Author

Oh, I had tried this property and it didn't work, so I had assumed it had a different purpose. It works now!

Just one little thing, I think the documentation and/or name of the property should be adjusted:

"showMinMaxRange: Whether to allow navigation past min/max dates."

Because when you set the property to true, the navigation is NOT allowed, contrary to what indicated above

Any way, thank you a lot!

@melloware
Copy link
Member

@acc-cassio do you have a recommendation for what the docs should say? I can make the change?

@melloware
Copy link
Member

how about this

Controls whether navigation beyond minimum and maximum dates is restricted. When true, navigation is limited to the min/max date range.

@acc-cassio
Copy link
Contributor Author

The suggestion sounds quite clear to me! Thank you!

@acc-cassio
Copy link
Contributor Author

Ideally the name of the property should be changed too, right? But I guess this is more complicated due to backwards compatibility?

@acc-cassio
Copy link
Contributor Author

I'd name it 'restrictMinMaxNav', to match the suggested description

@melloware
Copy link
Member

yeah i hate renaming props after they exist though and PR uses a lot of showXXX so i proabbly named it poorly to begin with 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior
Projects
None yet
Development

No branches or pull requests

2 participants