Vue-form-generator: Pikaday field: Invalid date

Created on 31 Aug 2016  路  7Comments  路  Source: vue-generators/vue-form-generator

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.

bug need investigate

All 7 comments

Could you make a fiddle with this issue?

Fiddle

Found more things:

  • if the model is not defined :arrow_right: empty field
  • if the model is defined with an empty String :arrow_right: "Invalid date" appear in the field
  • if the model is defined with a String in the same format defined :arrow_right: 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 :arrow_right: 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?

They say:

No dependencies (but plays well with Moment.js)

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 ?

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.

I edited the doc and pointed to this issue

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sjordan1975 picture sjordan1975  路  5Comments

ndro picture ndro  路  4Comments

icebob picture icebob  路  4Comments

blackfyre picture blackfyre  路  4Comments

jaywilburn picture jaywilburn  路  3Comments