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

Console spammed with Invalid date passed to the setViewDate #851

Open
mmatuk opened this issue Feb 7, 2023 · 0 comments
Open

Console spammed with Invalid date passed to the setViewDate #851

mmatuk opened this issue Feb 7, 2023 · 0 comments

Comments

@mmatuk
Copy link

mmatuk commented Feb 7, 2023

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant