Skip to content
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

Regression: nested MDX objects throw parse error #4484

Closed
jeffsee55 opened this issue Apr 9, 2024 · 2 comments · Fixed by #4485
Closed

Regression: nested MDX objects throw parse error #4484

jeffsee55 opened this issue Apr 9, 2024 · 2 comments · Fixed by #4485

Comments

@jeffsee55
Copy link
Member

Nested object structures in MDX template fields throw an error, config:

import { RichTextField } from '@tinacms/schema-tools'

export const field: RichTextField = {
  name: 'body',
  type: 'rich-text',
  parser: { type: 'mdx' },
  templates: [
    {
      name: 'Table',
      fields: [
        {
          name: 'rows',
          type: 'object',
          list: true,
          fields: [
            {
              name: 'columns',
              type: 'object',
              list: true,
              fields: [
                {
                  name: 'content',
                  type: 'rich-text',
                },
              ],
            },
          ],
        },
      ],
    },
  ],
}

And value:

<Table rows={[
    {
      columns: [
        {
          content: {
            type: "root",
            children: []
          }
        }
      ]
    }
  ]} />

Cause this error:

Unable to parse field value for field \"rows\" (type: object). Expected type to be Literal but received ObjectExpression
@jmarks-joshua
Copy link

For me this works as I'm embedding and entering the data for the template, but then gives this error only on refresh of the browser. Not sure if that is helpful, but thought I'd add just in case.

@JackDevAU
Copy link
Member

I'm excited to announce that the issue regarding nested MDX objects has been resolved 🎉

How to Update and Test:

Update your TinaCMS package to version 1.6.3:

npm i tinacms

Refer to this example (if you want to try it out): https://github.com/tinacms/tinacms/blob/598bb59701e05643d27d472b415d3b81c3ec27fc/packages/%40tinacms/mdx/src/next/tests/mdx-basic-nested-objects-2/field.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants