Skip to content

PM-1384 Fix date picker in copilot form #1144

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

Merged
merged 2 commits into from
Jul 23, 2025
Merged

PM-1384 Fix date picker in copilot form #1144

merged 2 commits into from
Jul 23, 2025

Conversation

himaniraghav3
Copy link
Collaborator

Related JIRA Ticket:

https://topcoder.atlassian.net/browse/PM-1384

What's in this PR?

Removes the previous years and shows only current and next two years in the year dropdown of date picker

@@ -76,7 +77,8 @@ const InputDatePicker: FC<InputDatePickerProps> = (props: InputDatePickerProps)
const datePickerRef = useRef<ReactDatePicker<never, undefined>>(null)
const years = useMemo(() => {
const maxYear = getYear(props.maxDate ? props.maxDate : new Date()) + 1
return range(1979, maxYear, 1)
const minYear = getYear(props.minYear ? props.minYear : 1979)
return range(minYear, maxYear, 1)
}, [props.maxDate])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency array for useMemo should include props.minYear as it is used to calculate minYear. This ensures that the memoized value updates correctly when props.minYear changes.

Copy link
Collaborator

@kkartunov kkartunov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@kkartunov kkartunov merged commit 8bb8aba into dev Jul 23, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants