Hotfix: Replace @blueprintjs/datetime with react-day-picker v9#3778
Conversation
…nto react-day-picker-v9
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request replaces the @blueprintjs/datetime dependency with a custom implementation of DateInput, DatePicker, and TimePicker built using react-day-picker. Feedback highlights several critical issues, including potential application crashes when calling toISOString on invalid dates and missing NaN checks during time parsing. There are also concerns regarding state synchronization in DateInput and DatePicker, logic errors that prevent clearing selections or setting times before a date is picked, and a type mismatch in the DateInput API compared to the component it replaces. Additionally, an unused prop with a TODO comment should be removed or tracked formally.
Coverage Report for CI Build 24393155027Coverage remained the same at 40.892%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
There was a problem hiding this comment.
Code Review
This pull request replaces the @blueprintjs/datetime dependency with a custom implementation of date and time pickers using react-day-picker v9. The changes introduce new DateInput, DatePicker, and TimePicker components and update existing references throughout the codebase. Feedback identifies several critical issues: the omission of required CSS for react-day-picker, the use of deprecated component keys in the DatePicker configuration, and state synchronization bugs in DatePicker and DateInput that prevent them from functioning correctly as controlled components. Additionally, improvements are suggested for TimePicker to handle invalid numeric inputs more robustly using Blueprint's onValueChange callback.
There was a problem hiding this comment.
Pull request overview
This PR removes @blueprintjs/datetime (which depends on react-day-picker v8 and breaks under React 19) and introduces local replacement components backed by react-day-picker v9 to keep the existing API surface mostly intact and prevent downstream changes.
Changes:
- Remove
@blueprintjs/datetimeand addreact-day-picker@^9.14.0dependency updates. - Introduce
src/commons/DateTimePickers(DatePicker,TimePicker,DateInput) and switch existing imports to use them. - Remove the Blueprint datetime stylesheet import.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Removes Blueprint datetime resolution and adds react-day-picker@9 (plus new transitive deps). |
| package.json | Drops @blueprintjs/datetime, adds react-day-picker. |
| src/styles/index.scss | Removes Blueprint datetime CSS import. |
| src/pages/academy/groundControl/subcomponents/GroundControlEditCell.tsx | Switches DateInput import to local wrapper. |
| src/pages/academy/gameSimulator/subcomponents/chapterPublisher/ChapterPublisherEditor.tsx | Switches DatePicker import to local wrapper. |
| src/commons/achievement/control/goalEditor/EditableTime.tsx | Switches TimePicker import to local wrapper. |
| src/commons/achievement/control/goalEditor/EditableDate.tsx | Switches DatePicker import to local wrapper. |
| src/commons/achievement/control/achievementEditor/EditableDate.tsx | Switches DatePicker import to local wrapper. |
| src/commons/DateTimePickers/index.ts | New barrel export for the wrapper components. |
| src/commons/DateTimePickers/TimePicker.tsx | New custom time picker built on Blueprint NumericInput. |
| src/commons/DateTimePickers/DatePicker.tsx | New calendar picker built on react-day-picker with Blueprint UI elements. |
| src/commons/DateTimePickers/DateInput.tsx | New input+popover wrapper combining InputGroup and the custom DatePicker. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| timePrecision, | ||
| disableTimezoneSelect | ||
| }) => { | ||
| void timePrecision; | ||
| void disableTimezoneSelect; |
There was a problem hiding this comment.
timePrecision and disableTimezoneSelect are accepted in the public props but explicitly ignored (void ...). Call sites pass these props (e.g. GroundControl) expecting behavior; ignoring them can be a functional regression compared to @blueprintjs/datetime. Either implement the relevant behavior (e.g. hide minutes/seconds based on timePrecision, omit timezone UI when disabled) or remove these props from the API to avoid a misleading interface.
There was a problem hiding this comment.
Intentional. This is a temporary migration
| import { Dialog, DialogBody, DialogFooter, Intent } from '@blueprintjs/core'; | ||
| import { DateInput } from '@blueprintjs/datetime'; | ||
| import { IconNames } from '@blueprintjs/icons'; | ||
| import dayjs from 'dayjs'; | ||
| import React, { useCallback, useState } from 'react'; | ||
| import { DateInput } from 'src/commons/DateTimePickers'; | ||
|
|
||
| import { AssessmentOverview } from '../../../../commons/assessment/AssessmentTypes'; | ||
| import ControlButton from '../../../../commons/ControlButton'; |
There was a problem hiding this comment.
Bug: Clearing the date input in GroundControlEditCell creates an invalid dayjs object that bypasses a !newDate check, leading to a crash or data corruption when .toISOString() is called.
Severity: HIGH
Suggested Fix
In GroundControlEditCell.tsx, enhance the validation within handleDateChange or handleUpdateDate. Instead of just checking for a truthy value with if (!newDate), use if (!newDate || !newDate.isValid()) to properly guard against invalid date objects before attempting to call .toISOString().
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/pages/academy/groundControl/subcomponents/GroundControlEditCell.tsx#L1-L8
Potential issue: When a user clears the `DateInput` field, the `onChange` callback is
triggered with `null`. In `GroundControlEditCell.tsx`, this results in `dayjs(null)`
being called, which creates an invalid but truthy `dayjs` object. A subsequent guard
clause, `if (!newDate)`, fails to catch this invalid state. The code then proceeds to
call `.toISOString()` on this invalid object. The exact outcome is uncertain, but it
will either throw a `RangeError`, causing a crash, or send an invalid date string to the
backend, causing data corruption.
There was a problem hiding this comment.
Not clearable at the moment, so it's fine
@blueprintjs/datetime with react-day-picker v9@blueprintjs/datetime with react-day-picker v9
|
Let's merge this hotfix to get the frontend working again. Proper fix is put in #3779 as an issue. |
Description
The former depends on v8 which doesn't work in React 19. We create our own custom component for now with the same API to minimize downstream dependent changes.
Fixes crashes in pages that depend on it
Type of change
How to test
Checklist