smrsan76 / imrc-datetime-picker

(Improved) React component datetime picker by momentjs :calendar:
https://imrc-datetime-picker.js.org/
MIT License
21 stars 10 forks source link

Date is not set if the input was clear before. #4

Closed gizmodesbois closed 5 years ago

gizmodesbois commented 5 years ago

Describe the bug When the input is clear, like in the example, we can't reselect a new one and make the update. No errors triggered in the console.

To Reproduce Steps to reproduce the behavior:

  1. Go to the examples page (https://imrc-datetime-picker.js.org/)
  2. Go to popup mode
  3. Click on the input
  4. Select the clear option
  5. Select an other date.

Expected behavior It should select the date and fill the input correctly.

Screenshots Small video of the example. https://take.ms/Fqgan

Please complete the following information

smrsan76 commented 5 years ago

Hi @gizmodesbois Thanks for reporting this issue.

The problem was the shortcut property which was just able to recognize moment.js objects.

But now, in v2.1.1, I added a new ability to this property to recognize both moment.js objects and option objects which can contain a callback property with a callback function.

Clearing date picker was able to cause the moment object to be empty, which can also cause date time picker not being able to select a new date.

Now in imrc-datetime-picker.js.org example, clearing date picker will just cause the cleared flag to be false. (not the moment state to be empty !)

However, despite clearing date picker, moment object is exist in the state. Therefore, it's your own responsibility to handle a logic which can prevent passing moment object when date picker is cleared.

If there was another issue, your next contributions are appreciated.