arqex / arqex/react-datetime

Console spammed with Invalid date passed to the `setViewDate`

Open
#851 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2k
Forks
858
PR merge metrics
No merged PRs in 30d

Description

### I'm Submitting a ...

```
[ X] Bug report
[ ] Feature request
[ ] Support request
```

### Steps to Reproduce

Having a controlled DateTime with a value prop spams the console log with warning messages as the user types into the input field.

### Expected Results

Do not spam warning messages. Instead there should be a single warning once the user is finished typing a date out. It should be expected the the first character, or first couple of characters, in a date string would not be a valid date. So if the user types "12/12/2023", I should not see a warning message for every character until the user is finished the entire date and has left the input with an onBlur event .

### Actual Results

You see this being spammed in the console log after every character change as the user types.

![image](https://user-images.githubusercontent.com/9585972/217380328-6562dc7a-9c4b-49cd-842a-93dbd5dc0f68.png)

### Minimal Reproduction of the Problem

Go to the sandbox, type into the date field and watch the console logs.

https://codesandbox.io/s/react-datetime-invalid-date-warning-sp7fvt

### Other Information (e.g. stacktraces, related issues, suggestions how to fix)

Looks to be caused by the setViewDate function being called every time a user types in the input. This means it getting called with invalid dates since the user has not finished typing.

Maybe instead only fire this function once the user blurs the input or add some debouncing to the input to prevent warning messages that are not helpful.

Contributor guide

Open the contributing guide

Research direction

Start with the linked CodeSandbox reproduction and observe the controlled DateTime while typing. Trace the setViewDate calls triggered by input changes and verify the console warning behavior; done means incomplete typing no longer produces a warning for every character, while a single warning can appear after the input is finished and blurred.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.