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

DatePicker OnBlur event passes String instead of Date #447

Closed
IronSean opened this issue Jan 16, 2020 · 2 comments
Closed

DatePicker OnBlur event passes String instead of Date #447

IronSean opened this issue Jan 16, 2020 · 2 comments

Comments

@IronSean
Copy link

I'm submitting a...

  • Bug report

Current behavior

The OnBlur event fired by the @progress/kendo-react-dateinput DatePicker component passes an OnBlur event. This OnBlur event contains a value which represents the formatted text value of the inputbox, not the Date value of the input. The OnChange event passes a Date object as the value. This discrepancy caused an issue with a form handling library react-hook-form as it reads the value from OnBlur and saves it too, then passes it back to DatePicker which fails the proptype check as a String is not a Date.

Expected behavior

I would expect the Value types to be the same on both OnChange and OnBlur

Minimal reproduction of the problem with instructions

Can be seen on this CodeSandbox:
https://codesandbox.io/s/broken-thunder-9f4m3

What is the motivation or use case for changing the behavior?

To have consistency in the OnChange and OnBlur events, and to fix the integration with react-hook-form

Environment

Package versions:
Can be seen in CodeSandbox, latest kendo(3.10.0), react(16.8.4), and react-hook-form(4.5.5)

Browser:

  • Chrome (desktop) version 79.0.3945.117
@IronSean
Copy link
Author

I also opened react-hook-form/react-hook-form#854 in the react-hook-form repo as the fact that they read the values from the OnBlur also seems strange.

@Xizario
Copy link
Contributor

Xizario commented Feb 11, 2020

The picker is composite component and you will get the blur many times when changing in between the calendar and the input and also gives you the native blur event of the elements from inside it.

You can wrap the picker, store the value using onChange, and use the last stored value in your blur handler if this is needed.

We are not going to add wrapped blur callback with value, since it will be async, and can lead to further problems.

@Xizario Xizario closed this as completed Feb 11, 2020
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

2 participants