fix(rich-text-versioning): pin react-query v4 to fix editor load crash []#11048
fix(rich-text-versioning): pin react-query v4 to fix editor load crash []#11048david-shibley-contentful wants to merge 1 commit into
Conversation
Vite was hoisting @tanstack/react-query v5 from field-editor-shared, which left FetchingWrappedInlineEntryCard treating in-flight fetches as success and reading entry.sys before data loaded. Pin v4 at the app level so embedded reference cards use loading status correctly. Also harden the version comparison dialog against missing link targets and fix stale state when fetching content types for embedded entries. Co-authored-by: Cursor <cursoragent@cursor.com>
| if (contentTypeIds.length > 0) { | ||
| const fetchedContentTypes = await sdk.cma.contentType.getMany({ | ||
| query: { | ||
| 'sys.id[in]': contentTypeIds.join(','), |
There was a problem hiding this comment.
Just in case: this is changing from an array to a comma-separated string, but I'd expect either work
There was a problem hiding this comment.
Good call. Either should work with the CMA client. I used .join(',') here to match getEntries / getAssets in this file, not because the array form was failing.
The meaningful change in this block is using the freshly fetched entries (instead of stale state), deduping IDs, and guarding missing contentType refs. Happy to switch back to passing the array if you prefer consistency with the old line rather than with the other queries in Dialog.tsx.
There was a problem hiding this comment.
No need! As long as the CMA accepts both, it's good
ryunsong-contentful
left a comment
There was a problem hiding this comment.
consider if the .join is needed for efficiency purposes
Summary
@tanstack/react-query@4.44.0as a direct dependency so Vite bundles v4 instead of hoisting v5 from@contentful/field-editor-sharedCannot read properties of undefined (reading 'sys')when loading the rich text editor on fields with embedded entry/asset referencesRoot cause
With react-query v5 hoisted,
FetchingWrappedInlineEntryCardin@contentful/field-editor-rich-text@6.3.9does not treat'pending'as a loading state. The success branch renders before entity data is available and accessesentry.sys.Test plan
npm run buildpasses inapps/rich-text-versioningnpm testpasses (32 tests)Made with Cursor