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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/apps/copilots/src/pages/copilot-request-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ const CopilotRequestForm: FC<{}> = () => {
error={formErrors.startDate}
dirty
minDate={new Date()}
maxDate={new Date(new Date()
.setFullYear(new Date()
.getFullYear() + 2))}
minYear={new Date()}
/>
<p className={styles.formRow}>How many weeks will you need the copilot for?</p>
<InputText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface InputDatePickerProps {
readonly maxTime?: Date | undefined
readonly minDate?: Date | null | undefined
readonly minTime?: Date | undefined
readonly minYear?: Date | null |undefined
readonly placeholder?: string
readonly showMonthPicker?: boolean
readonly showYearPicker?: boolean
Expand Down Expand Up @@ -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.


const [stateHasFocus, setStateHasFocus] = useState(false)
Expand Down