Skip to content

Commit

Permalink
Fix value bindings not always causing updates (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
asdfghjkkl11 authored Nov 6, 2024
1 parent bacf29f commit 897e83f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## Next
- Fix value bindings not always causing updates (@asdfghjkkl11)

## 2.14.0 - 2024 Oct 23
- Add Svelte 5 support

Expand Down
6 changes: 5 additions & 1 deletion src/lib/DateInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
/** Default date to display in picker before value is assigned */
const defaultDate = new Date()
function cloneDate(d: Date) {
return new Date(d.getTime())
}
// inner date value store for preventing value updates (and also
// text updates as a result) when date is unchanged
const innerStore = writable(null as Date | null)
Expand All @@ -27,7 +31,7 @@
innerStore.set(null)
value = date
} else if (date.getTime() !== $innerStore?.getTime()) {
innerStore.set(date)
innerStore.set(cloneDate(date))
value = date
}
},
Expand Down

0 comments on commit 897e83f

Please sign in to comment.