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

Range DatePicker throws an error on onChange handler #78

Closed
the-dr-lazy opened this issue Dec 8, 2019 · 3 comments
Closed

Range DatePicker throws an error on onChange handler #78

the-dr-lazy opened this issue Dec 8, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@the-dr-lazy
Copy link
Contributor

Describe the bug
Range date picker throws an error on onChange handler. There is no issue with single day nor multiple days selector.

Reproduced Version on CodeSandbox
Here it is on CodeSandBox

Expected behavior
It should run the onChange handler without throwing any exception.

@the-dr-lazy the-dr-lazy added the bug Something isn't working label Dec 8, 2019
@Kiarash-Z
Copy link
Owner

@thebrodmann First off, it seems that CodeSandbox isn't throwing the intended error. If you check this on your local machine it would throw an error like this:

image

That's because of the initial value of { from: undefined, to: undefined } instead of { from: null, to: null }, and why is that happening? because I deep clone value using JSON.parse(JSON.stringify(obj)), and interestingly, JSON.stringify will omit keys with the value of undefined when converting them to string, but if they have a value of null it will keep them. This behavior can be changed by changing deepCloneObject utility though, but I'm not quite sure for support for value undefined for range value keys instead of null.

@the-dr-lazy
Copy link
Contributor Author

I'm not quite sure for support for value undefined for range value keys instead of null.

It causes a breaking change. I think we should change the TypeScript type definition to just allow null type for range date selector.
I'm going to close this issue as it's intentional behavior.
Thank you.

@Kiarash-Z Kiarash-Z mentioned this issue Dec 8, 2019
@Kiarash-Z
Copy link
Owner

Kiarash-Z commented Dec 8, 2019

@thebrodmann have you checked v1.1.1? now it support { from: undefined, to: undefined }

@Kiarash-Z Kiarash-Z reopened this Dec 8, 2019
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

No branches or pull requests

2 participants