palantir/blueprint

DateRangeInput: parseDate Fn could give info about which field it is parsing either startDate or EndDate

Open

#5986 opened on Mar 1, 2023

View on GitHub
 (0 comments) (0 reactions) (0 assignees)TypeScript (20,263 stars) (2,167 forks)batch import
P2Package: datetimeType: feature requesthelp wanted

Description

Environment

  • Package version(s): 4.16.3
  • Browser and OS versions: chorme latest

Feature request

when we manually edit the date field either startDate or endDate , the parseDate Fn is called to parse the date string we edited in the input element.

When calling the parseDate function, if the component provides more info about which field either startdate field or endDate field it is parsing, it will be useful.

In case of controlled components, if the user entered date is invalid, I could replace the previous version , but unfortunately the component is replacing the current date value.

see the parseDate fn, returning the currentDate in case of an invalid string in the input.

Screenshot 2023-02-28 at 17 44 52

Examples

see the code sandbox https://codesandbox.io/s/recursing-wing-1phcb9?file=/src/datepicker.tsx in line #50,51,52, where I like to return the previous value of the date field in case of invalid date string, but i am unable to get which field the component is parsing the data.

It will be helpful , inside the parseDate fn , if any extra parameter telling me which field of data the function is currently processing incase of date range comp (we have two fields start and end date field)

Contributor guide