tabuckner / material-dayjs-adapter

A MatDateAdapter for Dayjs
https://www.npmjs.com/package/@tabuckner/material-dayjs-adapter
15 stars 23 forks source link

Non-locale based date strings break when using newer versions of dayjs #51

Open csaphiro opened 2 years ago

csaphiro commented 2 years ago

I'm using:

When using a custom date format the datepicker does not recognize the user typing in a date due to an error:

ERROR TypeError: Cannot read properties of undefined (reading 'replace')
at :4200/vendor.js:95004
    at a (:4200/vendor.js:95004)
    at Object.longDateFormat (:4200/vendor.js:95004)
    at DayjsDateAdapter.parse (:4200/main.js:130)
    at MatDatepickerInput._onInput (:4200/vendor.js:87072)
    at MatDatepickerInput_input_HostBindingHandler (:4200/vendor.js:87130)
    at executeListenerWithErrorHandling (:4200/vendor.js:48548)
    at wrapListenerIn_markDirtyAndPreventDefault (:4200/vendor.js:48597)
    at HTMLInputElement.<anonymous> (:4200/vendor.js:92678)
    at ZoneDelegate.invokeTask (:4200/polyfills.js:412)

This appears to be due to a change in dayjs longDateFormat in a recent version

BastianGanze commented 2 years ago

I get the same error if I use "dayjs": "1.9.8",. With "dayjs": "1.8.36", another error happens in the format function. 😢 Makes me wonder if the parse function was ever tested with custom date format to begin with.

TommiSvard commented 2 years ago

Im facing the same issue, did you find a solution to your problem @BastianGanze / @csaphiro ?