Skip to content

Commit 74277a0

Browse files
committed
changeset
1 parent da27275 commit 74277a0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
"@tanstack/db": patch
3+
---
4+
5+
Fix change tracking for array items accessed via iteration methods (find, forEach, for...of, etc.)
6+
7+
Previously, modifications to array items retrieved via iteration methods were not tracked by the change proxy because these methods returned raw array elements instead of proxied versions. This caused `getChanges()` to return an empty object, which in turn caused `createOptimisticAction`'s `mutationFn` to never be called when using patterns like:
8+
9+
```ts
10+
collection.update(id, (draft) => {
11+
const item = draft.items.find(x => x.id === targetId)
12+
if (item) {
13+
item.value = newValue // This change was not tracked!
14+
}
15+
})
16+
```
17+
18+
The fix adds proxy handling for array iteration methods similar to how Map/Set iteration is already handled, ensuring that callbacks receive proxied elements and returned elements are properly proxied.

0 commit comments

Comments
 (0)