-
-
Notifications
You must be signed in to change notification settings - Fork 924
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(DateRangePicker): limit start year #3151
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
@loposkin is attempting to deploy a commit to the rsuite Team on Vercel. A member of the Team first needs to authorize it. |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 9e9d1d6:
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #3151 +/- ##
==========================================
+ Coverage 93.43% 93.44% +0.01%
==========================================
Files 562 563 +1
Lines 20395 20415 +20
Branches 2739 2740 +1
==========================================
+ Hits 19056 19077 +21
Misses 694 694
+ Partials 645 644 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
@simonguo, do I need to do something else? Looks like the authorization is missing on some test stage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @loposkin, thank you for contributing this edit!
As this PR adds new APIs, please add test cases to ensure the API work as expected.
@SevenOutman, I've added a test for a |
expect(getAllByRole('row', { hidden: true })).to.be.lengthOf(2); | ||
expect(getAllByRole('rowheader', { hidden: true })[0].innerText).to.be.eq( | ||
previousYear.toString() | ||
); | ||
expect(getAllByRole('rowheader', { hidden: true })[1].innerText).to.be.eq( | ||
currentYear.toString() | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me confirm this. Does it mean that limitStartYear={1}
results in the earliest year be 1 year before current, while limitEndYear={1}
results in the latest year be just current year? If so, I don't think it's consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, yes, you're right and yes, it's not consistent. The limitStartYear={1} results in the earliest year that is 1 year before current, while limitEndYear={1} results in the current year. The problem is that I only propagate the props to existent MonthDropdown
-API. Should I change this API? I think it would mean a breaking change for people who already use MonthDropdown.
Hi @loposkin If the limitStartYear?: number | ((activeDate: Date) => number);
limitEndYear?: number | ((activeDate: Date) => number); where the <DateRangePicker limitStartYear={1990} limitEndYear={2023} />
<DateRangePicker
limitStartYear={(activeDate: Date) => {
return addDays(getYear(activeDate), -5);
}}
limitEndYear={(activeDate: Date) => {
return addDays(getYear(activeDate), 5);
}}
/>; Also |
@simonguo @SevenOutman , I've changed the API according to @simonguo suggestion. I've also updated
I've updated the english documentation accordingly, unfortunatelly, I am missing required language skills to update the documentation in Chinese. As for functional values for |
@loposkin, MonthDropdown is an internal component that's not exported as a public API, so I think it's OK to either change it's
@simonguo, the |
@SevenOutman, so if I change the api to be consistent to existent |
It's going to be merged. |
@SevenOutman, I've opened another PR with requested changes. |
CHANGES
Added
limitStartYear
prop to DateRangePicker. Usage:This looks like:
![limit_start_year](https://user-images.githubusercontent.com/21282847/230661533-9e520080-f132-4a7d-929e-836f848d88f3.png)
If unset, the start year still defaults to 1900
ISSUE
close #3145