palantir/blueprint

DateRangeInput2 parseDate user entering an invalid date returns valid date

オープン

#6,412 opened on 2023/09/26

 (2 件のコメント) (0 件のリアクション) (0 人の担当者)TypeScript (2,167 件のフォーク)batch import
Package: datetimeType: bughelp wanted

Repository metrics

Stars
 (20,263 個のスター)
PR merge metrics
 (平均マージ 43d 10h) (30d で 27 merged PRs)

説明

Environment

  • Package version(s):
    • Blueprint v4.20.2, Datetime v4.4.37, Datetime2 v0.9.37.
    • Blueprint v5.x DateRangeInput3
  • Operating System: macOS Sonoma 14.0.0
  • Browser name and version: Google Chrome Version 118.0.5993.117 (Official Build) (x86_64)

Problem

Blueprint 4's DateRangeInput2's parseDate()

parseDate() returns a valid date even if the user inputs an invalid date (it returns the current date). This means that onError is never called based on this logic.

This is also present in Blueprint 5's DateRangeInput 3's parseDate().

Code sandbox

https://codesandbox.io/s/clever-snow-65sg9m?file=/src/App.js

Steps to reproduce

Using the sandbox:

  1. Type 01-Jan-2023, 00:00 into the Start date
  2. Type abcdef into the End Date

https://github.com/palantir/blueprint/assets/50017873/2a879499-5296-491f-9f0e-4732c899b34b

Actual behavior

Today's date is entered into the End date.

Expected behavior

The 'Invalid date' is entered into the End date.

Solution

Perhaps revert back to Blueprint v3's implementation return newDate === false ? new Date(undefined) : newDate;

コントリビューターガイド