Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Hotfix: Replace @blueprintjs/datetime with react-day-picker v9#3778

Merged
RichDom2185 merged 10 commits into
masterfrom
react-day-picker-v9
Apr 14, 2026
Merged

Hotfix: Replace @blueprintjs/datetime with react-day-picker v9#3778
RichDom2185 merged 10 commits into
masterfrom
react-day-picker-v9

Conversation

@RichDom2185
Copy link
Copy Markdown
Member

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

How to test

Checklist

  • I have tested this code
  • I have updated the documentation

@RichDom2185 RichDom2185 requested a review from Nocaxe April 14, 2026 09:45
@RichDom2185 RichDom2185 self-assigned this Apr 14, 2026
@RichDom2185 RichDom2185 requested a review from Copilot April 14, 2026 09:46
@RichDom2185
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread src/commons/DateTimePickers/DateInput.tsx
Comment thread src/commons/DateTimePickers/DateInput.tsx
Comment thread src/commons/DateTimePickers/DatePicker.tsx Outdated
Comment thread src/commons/DateTimePickers/TimePicker.tsx
Comment thread src/commons/DateTimePickers/DateInput.tsx
Comment thread src/commons/DateTimePickers/DatePicker.tsx Outdated
Comment thread src/commons/DateTimePickers/DatePicker.tsx
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 14, 2026

Coverage Report for CI Build 24393155027

Coverage remained the same at 40.892%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 13800
Covered Lines: 6087
Line Coverage: 44.11%
Relevant Branches: 7006
Covered Branches: 2421
Branch Coverage: 34.56%
Branches in Coverage %: Yes
Coverage Strength: 28.94 hits per line

💛 - Coveralls

Comment thread src/commons/DateTimePickers/DatePicker.tsx Outdated
Comment thread src/commons/DateTimePickers/DateInput.tsx
Comment thread src/commons/DateTimePickers/DatePicker.tsx
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread src/styles/index.scss
Comment thread src/commons/DateTimePickers/DatePicker.tsx
Comment thread src/commons/DateTimePickers/DatePicker.tsx Outdated
Comment thread src/commons/DateTimePickers/DatePicker.tsx
Comment thread src/commons/DateTimePickers/DateInput.tsx
Comment thread src/commons/DateTimePickers/TimePicker.tsx
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/datetime and add react-day-picker@^9.14.0 dependency 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.

Comment thread src/commons/DateTimePickers/DatePicker.tsx
Comment thread src/commons/DateTimePickers/DateInput.tsx
Comment thread src/commons/DateTimePickers/TimePicker.tsx
Comment thread src/commons/DateTimePickers/TimePicker.tsx
Comment thread src/commons/DateTimePickers/DatePicker.tsx Outdated
Comment thread src/commons/DateTimePickers/DatePicker.tsx
Comment thread src/commons/DateTimePickers/DatePicker.tsx Outdated
Comment thread src/commons/DateTimePickers/DateInput.tsx
Comment on lines +34 to +38
timePrecision,
disableTimezoneSelect
}) => {
void timePrecision;
void disableTimezoneSelect;
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Intentional. This is a temporary migration

Comment thread src/commons/DateTimePickers/DatePicker.tsx Outdated
Comment thread src/commons/DateTimePickers/DatePicker.tsx
Comment on lines 1 to 8
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';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not clearable at the moment, so it's fine

@RichDom2185 RichDom2185 changed the title Replace @blueprintjs/datetime with react-day-picker v9 Hotfix: Replace @blueprintjs/datetime with react-day-picker v9 Apr 14, 2026
@RichDom2185
Copy link
Copy Markdown
Member Author

Let's merge this hotfix to get the frontend working again. Proper fix is put in #3779 as an issue.

@RichDom2185 RichDom2185 merged commit 7f6b143 into master Apr 14, 2026
10 checks passed
@RichDom2185 RichDom2185 deleted the react-day-picker-v9 branch April 14, 2026 11:33
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.

3 participants