feat(lemon-ui): add date limit when selecting dates.#30259
Merged
Conversation
Contributor
There was a problem hiding this comment.
PR Summary
Added a new selectionPeriodLimit prop to LemonCalendarSelect component to restrict date selection ranges, with comprehensive test coverage and documentation.
- Added
getDateDisabledReasonfunction in/frontend/src/lib/lemon-ui/LemonCalendar/LemonCalendarSelect.tsxto handle date validation with limits - Added two new Storybook stories in
LemonCalendarSelect.stories.tsxdemonstrating limit functionality for both past and future selections - Refactored test code in
LemonCalendarSelect.test.tsxto reduce duplication with helper functions and added specific test cases for date limits - Integrated limit validation seamlessly with existing time selection functionality while maintaining backward compatibility
3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
Contributor
|
Size Change: +188 B (0%) Total Size: 9.75 MB ℹ️ View Unchanged
|
daibhin
approved these changes
Mar 21, 2025
andehen
approved these changes
Mar 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
We need to allow the user to update the stop date of experiments (a common practice), that is currently using the
LemmonCalendarSelectcomponent. We need to prevent the user from selecting a stop date before the experiment start date.To support this feature, we need to add a limit to how many days one can select forward or backward.
Changes
This PR adds a new optional
propto theLemonCalendarSelectcomponent so we can set a limit date. We also refactor the logic for setting a date to disable reason, add two new stories to storybook, and two more tests.Also, the tests have been refactored to improve readability and reduce code duplication.
To run the tests from the
/frontendfolder:Important
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Does this work well for both Cloud and self-hosted?
How did you test this code?