fix(content-manager): prevent crash when switching b/w content-types with same component/field names. #25262
+2
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a frontend crash (TypeError: content.map is not a function) that occurs in the Content Manager's List View.
The issue was caused by a state logic mismatch in ListViewPage.tsx. When a user navigates between two content types that share an component/field name but have different data structures—specifically switching from a Repeatable Component (array) to a String—the dashboard incorrectly attempts to render the string using the repeatable component's logic.
Root Cause
In the ListViewPage, when list.layout changes, we pass updated 'content' value but stale attribute.type value. And since component/field names are same, it finds that name key in the 'content' and tries to render repeatable component(array) for updated content-type(String), causing the error.
Changes
Modified 'headers' inside useMemo hook to use updated list.layout value instead of using displayedHeaders which is stale on the first re-render.
Related Issue
Fixes #25230
How to test it
Create Content Type A with a repeatable component named testField.
Create Content Type B with a short text field named testField.
Add data to both.
Navigate to the List View of A.
Click directly on Content Type B in the sidebar.
Result: The page now renders correctly instead of throwing a white-screen TypeError.
Checklist
My code follows the contribution guidelines.
I have performed a self-review of my own code.
I have linked the relevant issue.
I have verified the fix locally.