Watch a live product demo πŸ‘€ See how Sanity powers richer commerce experiences

Array of References Showing as Untitled When New References Added

34 replies
Last updated: Jan 15, 2021
Hello everyone,I was wondering if someone could help me with my problem?
Currently in a schema I defined fields of a custom type "section"(type :'object'). this schema contains an array of references. When I now try to add references, they are shown as untitled. how can i change that?

export default {
    title: 'Versprechen Page',
    name: 'promise',
    type: 'document',
    ...
    fields: [
        {
            name: 'section1',
            type: 'section',
            fieldset: 'sectionGroup0'
        },
        ... ]
}

export default {
    title: 'Abschnitt',
    name: 'section',
    type: 'document',
    fields: [
        ...
        {
            title: 'Content',
            name: 'content',
            type: 'array',
            of: [
                {
                    type: 'reference',
                    to: [
                        {type: 'pictureAndText'},
                        {type: 'titleAndText'},
                        {type: 'collection'},
                        {type: 'link'}
                    ]
                }
            ]
        },
       ...
    ],
}

Jan 14, 2021, 11:08 AM
have you tried adding a preview object? https://www.sanity.io/docs/previews-list-views

preview: {
  select: {
    title: "myFieldToUse"
  },
},
Jan 14, 2021, 11:33 AM
yea i did
Jan 14, 2021, 11:33 AM
nothing changed
Jan 14, 2021, 11:33 AM
export default{
    title: 'Titel und Text',
    name: 'titleAndText',
    type: 'document',
    fields: [
        {
            title: 'Title',
            name: 'title',
            type: 'string'
        },
        {
            title: 'Text',
            name: 'text',
            type: 'array',
            of:[
                {type:'block'}
            ]
        },
        {
            title: 'Custom Type',
            name: 'custom',
            type: 'string'
        },
    ],
    preview: {
        select: {
            title: 'title',
        },
        prepare(selection) {
            const {title} = selection
            return {
                title: title,
            }
        },
    }
}

Jan 14, 2021, 11:34 AM
thats the reference id like to link in the array
Jan 14, 2021, 11:34 AM
have you tried adding the preview inside the array?

to: [
  {
    type: 'pictureAndText'
    preview: {
      title: title
    }
  },
]

Jan 14, 2021, 11:36 AM
do the titles inside the title and text documents have a value at all?
Jan 14, 2021, 11:36 AM
(btw you can omit the prepare function if you're not manipulating the title)
Jan 14, 2021, 11:37 AM
yea they do
Jan 14, 2021, 11:40 AM
and it doesnt work with the title inside the array
Jan 14, 2021, 11:41 AM
strange … i've copied your setup and it works here
Jan 14, 2021, 11:42 AM
and when u chose one it shows?
Jan 14, 2021, 11:43 AM
the title
Jan 14, 2021, 11:43 AM
have you published your documents?
Jan 14, 2021, 11:44 AM
I can reproduce it when I publish a document without a title and fill it - and then forget publishing.
Jan 14, 2021, 11:45 AM
i published everything
Jan 14, 2021, 11:45 AM
which sanity version are you on?
Jan 14, 2021, 11:47 AM
I just upgraded and am getting a lot of untitled references as well!
Jan 14, 2021, 11:48 AM
upgraded today
Jan 14, 2021, 11:48 AM
so its a bug in sanity?
Jan 14, 2021, 11:48 AM
user Y
user M
seems something is off with the references since todays update
Jan 14, 2021, 11:49 AM
might be this thing https://github.com/sanity-io/sanity/pull/2212 ("merging this should be fairly low risk in terms of breaking existing functionality.")
Jan 14, 2021, 11:50 AM
so ill wait on a fix then?
Jan 14, 2021, 11:54 AM
or downgrade
Jan 14, 2021, 11:54 AM
whats the command to downgrade to previous version?
Jan 14, 2021, 11:54 AM
update sanity/base dependency in package.json with a fixed version before this release and run
yarn
or
npm install
again
"@sanity/base": "2.1.4",
Jan 14, 2021, 12:04 PM
awesome thanks
Jan 14, 2021, 12:04 PM
Thanks both πŸ™Œ we're looking into this and will release a fix asap. Sorry for the confusion, Tim!
Jan 14, 2021, 12:13 PM
No problem, GOOD SUPPORT!
Jan 14, 2021, 12:13 PM
a fix is out, works fine now after upgrading to 2.1.6 (
sanity upgrade
)
Jan 14, 2021, 12:44 PM
We just released
v2.1.6
, which should fix the issue πŸ™‚
Jan 14, 2021, 12:44 PM
awesome thank you
Jan 14, 2021, 12:46 PM
Ah, this was my issue too. Upgraded and fixed. Thanks
Jan 15, 2021, 3:27 AM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Related answers

Get more help in the community Slack

TopicCategoriesFeaturedRepliesLast Updated
After adding the subtitle and running this code npm run graphql-deploy It does nothingSep 15, 2020
how to limit a reference to just one entry in Studio reference input side versus the default as-many-entries-as-you-fill-in-an-array...Sep 18, 2020
Is it possible to fetch more than one "_type" using GROQ?Nov 2, 2020
I want to add a view with the Structure builder (S.view.component) where I list similar documents based on the title. What...Sep 23, 2020
Is there a structure builder example where the format of each preview for the document list is modified?Feb 3, 2021
I have an array of references to a country schema type but it always just returns NULL values for meJan 30, 2021
Hi, I need help with a query for getting the url of an image asset. Here is what I've been trying, but I only get the _ref...Dec 1, 2020
Sanity UI looks brilliant :smiley: Is something like the current date picker possible at the moment? I’m not sure if anicon...Dec 21, 2020
Hey everyone. I have been coding and may have potentially accidentally deleted something. Does anyone know how to resolve...Dec 26, 2020
Hello everyone and happy new year :raised_hands::skin-tone-2:, I have a problem with outputting Portable Text :disappointed:...Jan 1, 2021

Related contributions

Clean Next.js + Sanity app
- Template

Official(made by Sanity team)

A clean example of Next.js with embedded Sanity ready for recomposition.

Cody Olsen
Go to Clean Next.js + Sanity app

Blog with Built-in Content Editing
- Template

Official(made by Sanity team)

A Sanity-powered blog with built-in content editing and instant previews.

Go to Blog with Built-in Content Editing