fix(datepicker): workaround for new Date(..) inconsistency

This commit is contained in:
Sarah Vaupel 2019-10-25 15:54:12 +02:00
parent ea6e0af414
commit d24ebf8145

View File

@ -123,12 +123,17 @@ export class Datepicker {
throw new Error('Datepicker utility called on unsupported element!');
}
// format any existing dates to fancy display format on pageload
this.formatElementValue(true);
// FIXME dirty hack below; fix tail.datetime instead
// initialize tail.datetime (datepicker) instance
// get date object from internal format before datetime does nasty things with it
const parsedMomentDate = moment(this._element.value).toDate();
// initialize tail.datetime (datepicker) instance and let it do weird stuff with the element value
this.datepickerInstance = datetime(this._element, { ...datepickerGlobalConfig, ...datepickerConfig });
// reset date to something sane
this.datepickerInstance.selectDate(parsedMomentDate);
// insert the datepicker element (dt) after the form
this._element.form.parentNode.insertBefore(this.datepickerInstance.dt, this._element.form.nextSibling);