I am trying to use duet-date-picker with Thymeleaf (server-side rendering). It works as long as I don’t use the localization support.
I added this in a <script> tag in my page:
const picker = document.querySelector('duet-date-picker');
const DATE_FORMAT = /^(\d{1,2})\.(\d{1,2})\.(\d{4})$/;
if (picker) {
picker.dateAdapter = {
parse(value = '', createDate) {
try {
console.log('parsing' + value);
const matches = value.match(DATE_FORMAT);
if (matches) {
return createDate(matches[3], matches[2], matches[1]);
}
} catch (err) {
console.log(err);
}
},
format(date) {
console.log('formatting: ' + date);
return `${date.getDate()}.${date.getMonth() + 1}.${date.getFullYear()}`;
},
};
}
I see lot’s of formatting... statements, but never parsing... and also no error in the console.
When I check with dev tools, I see updates to the value attribute of <duet-date-picker>, but the value of the actual <input> is not updated. Due to this, my server-side thinks that nothing was selected. For some reason, that does not seem to be an issue when not using the localization support. Am I doing something wrong?
I can confirm it works with version 1.1.0. Thanks for the bugfix!
Sorry, this fell through the net. I’ll see if i can get a PR together tomorrow
I’m going to edit the issue title to better reflect the problem, hope that’s ok!
ok, great. I’ll wait for the update. Thanks!