Closed K-Leon closed 4 years ago
i am same issue , this component can't set end date from parent ,end date will reset to TODAY . i found the root cause is props order : end date before start date. So how to fix? custom code ?
Thank you @y3wegy / @K-Leon - Seems like we need custom sort()
here, so that start date happens before end date:
https://github.com/skratchdot/react-bootstrap-daterangepicker/blob/eedc6c52370d53da6d0b885e4d6410989eec9aa5/lib/index.js#L44
I might be able to look into this after work today, but PR's are welcomed. Now that this repo has unit tests (and storybook), we should add a simple reproducible test case, then we can fix it (and make sure it doesn't happen again).
It looks like @adewitt76 submitted a fix for this in #139 , but I never saw that. Someone can try to submit a similar PR.
closing this due to inactivity. please re-open if this is still an issue in v6.0.0 or greater
I just noticed a really problematic part in setOptionsFromProps. The function assumes that Object.keys delivers a specific order - it won't deliver this order reliable.
This results in issues if startDate is set after endDate. ( endDate get's reset )
https://github.com/skratchdot/react-bootstrap-daterangepicker/blob/eedc6c52370d53da6d0b885e4d6410989eec9aa5/lib/index.js#L47
If there's interest i'll send a bugfix ( moving endDate out of loop for now ).