palantir/blueprint
View on GitHubDateRangeInput2 parseDate user entering an invalid date returns valid date
Open
#6412 opened on Sep 26, 2023
Package: datetimeType: bughelp wanted
Description
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:
- Type
01-Jan-2023, 00:00into the Start date - Type
abcdefinto 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;