Skip to content

Commit 897e83f

Browse files
authored
Fix value bindings not always causing updates (#104)
1 parent bacf29f commit 897e83f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## Next
4+
- Fix value bindings not always causing updates (@asdfghjkkl11)
5+
36
## 2.14.0 - 2024 Oct 23
47
- Add Svelte 5 support
58

src/lib/DateInput.svelte

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
/** Default date to display in picker before value is assigned */
1717
const defaultDate = new Date()
1818
19+
function cloneDate(d: Date) {
20+
return new Date(d.getTime())
21+
}
22+
1923
// inner date value store for preventing value updates (and also
2024
// text updates as a result) when date is unchanged
2125
const innerStore = writable(null as Date | null)
@@ -27,7 +31,7 @@
2731
innerStore.set(null)
2832
value = date
2933
} else if (date.getTime() !== $innerStore?.getTime()) {
30-
innerStore.set(date)
34+
innerStore.set(cloneDate(date))
3135
value = date
3236
}
3337
},

0 commit comments

Comments
 (0)