Ability to dynamically change time constraints
I have a form with Start and End Time fields and I'd like to ensure that the End Time is after the Start Time, even if the user updates the Start Time. However, updating the timeConstraints during a re-render doesn't seem to change the constraints and doesn't allow me to dynamically adjust what the min hour should be. This appears to be caused by the timeConstraints being configured only during the mounting of the component and thus it does not use updates to this prop. This also seems to mostly be an issue when using the component as just a time picker because I believe switching between date and time views causes re-mounting of the TimeView and updates the constraints.
I've put together a CodePen exhibiting the issue here: http://codepen.io/anon/pen/JEoGzB.
I've also started work on a fix, but wanted to ask if I should include an option for enabling this behavior or just make it the base functionality of this option.
Hi @shank-eric.
Some of the props have those limitations, unfortunately. I generally like customization, but I want to know more of how you think. So the option you're referring to would be able to enable re-rendering when changing time in TimeView mode?
@simeg, it would change the TimeView component to update the timeConstraints during componentWillReceiveProps in addition to componentWillMount such that if an updated timeConstraints is passed in, it will be honored. Here's an initial pass at the change I made: https://github.com/EverFi/react-datetime/pull/1/files
I ran into this myself in a very similar situation (start and end times). I ended up handling the logic in a parent component of start and end react-datetime components, but the main reason that drove me that way was that I had other factors that would have made the timeConstraint method more complicated.
Having this feature would be useful though.
Hey @shank-eric @simeg @layneanderson has this feature been implemented yet? Thanks..!
Hi @manishbhatt94. No, it has not been implemented unfortunately.
Are there any plans to implement something like this? Didn't see it in v3, and have some interest in it. Is there perhaps a workaround?