Skip to content

Commit c60c7b4

Browse files
bjoergekristofferjs
authored andcommitted
[preview] Don't write ref attributes on materialized values (#580)
1 parent 804f8f6 commit c60c7b4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/@sanity/preview/src/createPathMaterializer.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ export default function createPathMaterializer(observeWithPaths) {
3636

3737
const nextHeads = uniq(missingHeads.map(path => [path[0]]))
3838

39+
const isRef = isReference(value)
3940
if (isReference(value) || isDocument(value)) {
40-
const id = isReference(value) ? value._ref : value._id
41-
return observeWithPaths(id, nextHeads)
42-
.switchMap(snapshot => {
43-
return materializePaths({...createEmpty(nextHeads), ...value, ...snapshot}, paths)
44-
})
41+
const id = isRef ? value._ref : value._id
42+
return observeWithPaths(id, nextHeads).switchMap(snapshot => {
43+
return materializePaths({
44+
...createEmpty(nextHeads),
45+
...(isRef ? {} : value),
46+
...snapshot
47+
}, paths)
48+
})
4549
}
4650
}
4751

0 commit comments

Comments
 (0)