Skip to content

Commit f988feb

Browse files
committed
fix: svelte unsafe mutation
1 parent faf1613 commit f988feb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/famous-candles-visit.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@zag-js/date-picker": patch
3+
---
4+
5+
Fix issue where Svelte throws a `state_unsafe_mutation` error when controlling the datepicker range mode.

packages/machines/date-picker/src/date-picker.utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function isDateWithinRange(date: DateValue, value: (DateValue | null)[])
1515
}
1616

1717
export function sortDates(values: DateValue[]) {
18-
return values.sort((a, b) => a.compare(b))
18+
return values.slice().sort((a, b) => a.compare(b))
1919
}
2020

2121
export function getRoleDescription(view: DateView) {

0 commit comments

Comments
 (0)