Array of References Showing as Untitled When New References Added
34 replies
Last updated: Jan 15, 2021
T
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?
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
A
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
T
yea i did
Jan 14, 2021, 11:33 AM
T
nothing changed
Jan 14, 2021, 11:33 AM
T
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
T
thats the reference id like to link in the array
Jan 14, 2021, 11:34 AM
A
have you tried adding the preview inside the array?
to: [ { type: 'pictureAndText' preview: { title: title } }, ]
Jan 14, 2021, 11:36 AM
A
do the titles inside the title and text documents have a value at all?
Jan 14, 2021, 11:36 AM
A
(btw you can omit the prepare function if you're not manipulating the title)
Jan 14, 2021, 11:37 AM
T
yea they do
Jan 14, 2021, 11:40 AM
T
and it doesnt work with the title inside the array
Jan 14, 2021, 11:41 AM
A
strange ā¦ i've copied your setup and it works here
Jan 14, 2021, 11:42 AM
T
and when u chose one it shows?
Jan 14, 2021, 11:43 AM
A
the title
Jan 14, 2021, 11:43 AM
A
have you published your documents?
Jan 14, 2021, 11:44 AM
A
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
T
i published everything
Jan 14, 2021, 11:45 AM
A
which sanity version are you on?
Jan 14, 2021, 11:47 AM
A
I just upgraded and am getting a lot of untitled references as well!
Jan 14, 2021, 11:48 AM
T
upgraded today
Jan 14, 2021, 11:48 AM
T
so its a bug in sanity?
Jan 14, 2021, 11:48 AM
A
user Y
user M
seems something is off with the references since todays updateJan 14, 2021, 11:49 AM
A
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
A
Jan 14, 2021, 11:52 AM
T
so ill wait on a fix then?
Jan 14, 2021, 11:54 AM
A
or downgrade
Jan 14, 2021, 11:54 AM
T
whats the command to downgrade to previous version?
Jan 14, 2021, 11:54 AM
A
update sanity/base dependency in package.json with a fixed version before this release and run
yarnor
npm installagain
"@sanity/base": "2.1.4",
Jan 14, 2021, 12:04 PM
T
awesome thanks
Jan 14, 2021, 12:04 PM
P
Thanks both š we're looking into this and will release a fix asap. Sorry for the confusion, Tim!
Jan 14, 2021, 12:13 PM
T
No problem, GOOD SUPPORT!
Jan 14, 2021, 12:13 PM
A
a fix is out, works fine now after upgrading to 2.1.6 (
sanity upgrade)
Jan 14, 2021, 12:44 PM
P
We just released
v2.1.6, which should fix the issue š
Jan 14, 2021, 12:44 PM
T
awesome thank you
Jan 14, 2021, 12:46 PM
J
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.