-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI crash in collection with JSON field when data is a JSON array #9111
Comments
Hi @rbruels , I've encountered this same error when using just an empty array as a JSON field value. I'll see if this is connected. |
Hi @kendelljoseph — it definitely occurs when the value is a JSON array with multiple elements. We discovered it because our JSON field had an array with >100 elements. See my diagnosis above:
|
Yep. I have reproduced it on my end. They are connected. The cellData can also be an array, and arrays don't have the substring property. I should have a fix for this ready soon! |
Rad!! Now we just need work on migrating to 3.0 😅 Thanks @kendelljoseph |
Describe the Bug
The collection list view crashes if the collection has a
JSON
field which contains an array with greater than 100 items.The error is:
Link to the code that reproduces this issue
https://github.com/rbruels/payload-json-issue
Reproduction Steps
Add json field
I just added this to the default
Media
collection:Insert data
Insert a new
Media
object and add an image/alt text and then in the newdata
field, add a json array exceeding 100 items. You can copy paste this if you're so inclined:Save the object.
Reload the list view
Go back to the list view for media (http://localhost:3000/admin/collections/media)
You'll immediately see an error:
The problematic code is here:
https://github.com/payloadcms/payload/blob/beta/packages/ui/src/elements/Table/DefaultCell/fields/JSON/index.tsx#L11
In this case,
cellData
is a json array. SocellData.length > 100
is valid code ... but when the # of objects in the array exceeds 100, it callscellData.substring
which is not valid for the array.Which area(s) are affected? (Select all that apply)
area: ui
Environment Info
The text was updated successfully, but these errors were encountered: