Skip to content

Pikaday field: Invalid date #59

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

Closed
lionel-bijaoui opened this issue Aug 31, 2016 · 7 comments
Closed

Pikaday field: Invalid date #59

lionel-bijaoui opened this issue Aug 31, 2016 · 7 comments

Comments

@lionel-bijaoui
Copy link
Member

lionel-bijaoui commented Aug 31, 2016

When I use a pikaday field with no special options, I get "Invalid date" in the field.
I can see the good value for a fraction of a second but then it get replaced by this message.
This problem don't appear with the dev environment, and I suspect it has something to do with Moment.js (or the lack of it to be precise).
I experimented a bit with format, but nothing change that.
For now I will send a PR which don't add any default values (except field) in pikadayOptions.

@icebob
Copy link
Member

icebob commented Sep 1, 2016

Could you make a fiddle with this issue?

@lionel-bijaoui
Copy link
Member Author

lionel-bijaoui commented Sep 1, 2016

Fiddle

Found more things:

  • if the model is not defined ➡️ empty field
  • if the model is defined with an empty String ➡️ "Invalid date" appear in the field
  • if the model is defined with a String in the same format defined ➡️ the date appear into the field but at first (without any interaction) the format is not respected (eg. "Thu Sep 01 2016" instead of "2016-09-01"). When a value is selected, for a split second the non formatted value appear then the good format replace it.
  • if the model is defined with an empty Object ➡️ the date appear into the field but at first (without any interaction) the format is not respected (eg. "Thu Sep 01 2016" instead of "2016-09-01"). When a value is selected, for a split second the non formatted value appear then the good format replace it.

So, even when the format is good or with an empty Object, the first value is not respecting the desired format, and this undesired format still appear for a split second.
We might need to capture the click events and stop propagation or use onSelect callback to launch formatValueToField. Also maybe launch picker.setDate('2015-01-01') (or picker.setMoment(moment('14th February 2014', 'DDo MMMM YYYY'))) at the ready hook just after initialization.
What do you think ?

EDIT: When Moment.js is loaded, no more problem. Is Moment.js required for Pikaday?

@icebob
Copy link
Member

icebob commented Sep 1, 2016

They say:

No dependencies (but plays well with Moment.js)

@lionel-bijaoui
Copy link
Member Author

I know, but try to remove moment.js from the dev test files and use Pikaday to select a date. You will get "Invalid date". This may not be our fault, because I don't see where we use it without importing it first.
What do you think we should do ? Change the documentation ? Try to find and correct the bug ?

@icebob
Copy link
Member

icebob commented Sep 1, 2016

For quick solution please add the momentjs to pikaday as dependencies in the documentation. If I have more time, I will try to find the exact problem.

@lionel-bijaoui
Copy link
Member Author

I edited the doc and pointed to this issue

@icebob
Copy link
Member

icebob commented Feb 14, 2017

Maybe it is fixed in #118 and momentjs removed and pikaday working.

@icebob icebob closed this as completed Feb 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants