diff --git a/CHANGELOG.md b/CHANGELOG.md index 586e599..db81362 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Next +- Fix month/year not updating when `value` is assigned to + ## 2.2.4 - 2022 Dec 1 - Fix buttons causing form submissions diff --git a/src/lib/DatePicker.svelte b/src/lib/DatePicker.svelte index f230bbd..ecd18af 100644 --- a/src/lib/DatePicker.svelte +++ b/src/lib/DatePicker.svelte @@ -32,6 +32,9 @@ /** The date shown in the popup when none is selected */ let browseDate = value ? cloneDate(value) : cloneDate(defaultDate) + $: if (browseDate.getTime() !== value?.getTime()) { + browseDate = value ? cloneDate(value) : browseDate + } /** The earliest year the user can select */ export let min = new Date(defaultDate.getFullYear() - 20, 0, 1)