palantir/blueprint

DateRangeInput2 parseDate user entering an invalid date returns valid date

开放

#6,412 创建于 2023年9月26日

 (2 条评论) (0 个反应) (0 位负责人)TypeScript (2,167 个派生)batch import
Package: datetimeType: bughelp wanted

仓库指标

星标
 (20,263 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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;

贡献者指南