Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle cleared and invalid date values #296

Merged
merged 3 commits into from
Aug 30, 2023
Merged

Conversation

qroll
Copy link
Contributor

@qroll qroll commented Aug 30, 2023

Resolves #294

Changes

  • Fix issue where cleared values resulted in "Invalid Date"s on the calendar day grid
  • Fix issue where invalid dates like "xxx-x-x" results in NaN display in the date input
  • [delete] branch

Changelog entry

Bug fixes

  • Handle display of cleared and invalid date values in DateInput and DateRangeInput

@qroll qroll requested a review from keithtxw August 30, 2023 01:53
@@ -31,4 +28,14 @@ export namespace DateInputHelper {

return false;
};

export const sanitizeInput = (date: string): string => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this helps to convert invalid date strings like "2023-x-x" to an empty string (i.e. those values get ignored)

@@ -80,4 +80,8 @@ export namespace DateHelper {
const endTime = dayjs(end, format);
return endTime.diff(startTime, "minute");
};

export const toDayjs = (date: string): Dayjs => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to circumvent the behaviour where dayjs("") results in invalid day instead of returning the current day like dayjs(undefined)

@keithtxw keithtxw merged commit 6f89545 into master Aug 30, 2023
1 check passed
@keithtxw keithtxw deleted the handle-cleared-date-input branch August 30, 2023 08:00
@qroll qroll added this to the v2.1.0-canary.3 milestone Aug 30, 2023
@qroll qroll added the bug Something isn't working label Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug when user tries to clear the date in the DateInput component
2 participants