Unlock seamless workflows and faster delivery with our latest releases ā€“ get the details

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

Sanity is a 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.

Was this answer helpful?