palantir/blueprint

DateRangeInput2 parseDate user entering an invalid date returns valid date

Open

#6,412 建立於 2023年9月26日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)TypeScript (2,167 fork)batch import
Package: datetimeType: bughelp wanted

倉庫指標

Star
 (20,263 star)
PR 合併指標
 (平均合併 43天 10小時) (30 天內合併 27 個 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;

貢獻者指南