onefinestay / react-daterange-picker

Other
563 stars 209 forks source link

initialMonth: 0, does not work #193

Closed james-ff closed 6 years ago

james-ff commented 6 years ago

Hi,

I have encountered an issue which arrises when initialMonth is set to 0 (January). Set from any other month value 1-11 (February-December) the prop provides the expected result, the same goes for initialYear.

When 0 is passed to this prop the inital date for the given calendar is set to the current date instead.

I have done some tracking down of the issue and have found the cause to be this line (DateRangePicker.jsx:127):

127: if (initialYear && initialMonth) {

These props are passed in as number literals, and when set to 0 fail this conditional, which should if passed set up the initialMonth and initialYear to be used in the rendering of the component.

Any suggestions on what this conditional should be instead?

james-ff commented 6 years ago

@AlanFoster Which is the best replacement here? I can make a PR when I know which to go for

AlanFoster commented 6 years ago

@james-ff Thanks for the issue; This is a similar PR that aimed to fix this bug - https://github.com/onefinestay/react-daterange-picker/pull/164

I'm happy to accept a fresh PR with some tests that fixes this :)

james-ff commented 6 years ago

@AlanFoster Hi Alan, that PR looks like a good solution, just curious as to what is missing?

AlanFoster commented 6 years ago

@james-ff There's an open question, as well as some missing tests

I'm happy for you to put up a fresh PR that completes the remaining work required though 🎉

james-ff commented 6 years ago

https://github.com/onefinestay/react-daterange-picker/pull/195

AlanFoster commented 6 years ago

Released as 2.0.1 - let me know if there's any issues 👌

james-ff commented 6 years ago

Issue Solved