Skip to content

Fix edge case setting the month one forward

Choose a tag to compare

@felixkempf felixkempf released this 13 Nov 14:25
· 24 commits to master since this release

This release fixes a critical bug where, if the current day is not present in the month you have set into the inputs programmatically, the whole date shown in the date input picker is moved one month ahead.

For example, you are rendering a date input in an edit form where the date should be prefilled with 5th of November but the current date is the 31st of October, the date input would have shown the 5th of December.

This is due to the used JS method Date.setMonth, where if the second argument is not set, it will use the day of month of the current date and if this day is not present in the set month, the month of the resulting date will be one after the value given to the setMonth function. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth#Description