Issue with untitled references in Sanity schema resolved with upgrade to v2.1.6
36 replies
Last updated: Jan 15, 2021
C
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
B
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
C
yea i did
Jan 14, 2021, 11:33 AM
C
nothing changed
Jan 14, 2021, 11:33 AM
C
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
C
thats the reference id like to link in the array
Jan 14, 2021, 11:34 AM
B
have you tried adding the preview inside the array?
to: [ { type: 'pictureAndText' preview: { title: title } }, ]
Jan 14, 2021, 11:36 AM
B
do the titles inside the title and text documents have a value at all?
Jan 14, 2021, 11:36 AM
B
(btw you can omit the prepare function if you're not manipulating the title)
Jan 14, 2021, 11:37 AM
C
yea they do
Jan 14, 2021, 11:40 AM
C
and it doesnt work with the title inside the array
Jan 14, 2021, 11:41 AM
B
strange β¦ i've copied your setup and it works here
Jan 14, 2021, 11:42 AM
C
and when u chose one it shows?
Jan 14, 2021, 11:43 AM
B
the title
Jan 14, 2021, 11:43 AM
B
have you published your documents?
Jan 14, 2021, 11:44 AM
B
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
C
i published everything
Jan 14, 2021, 11:45 AM
B
which sanity version are you on?
Jan 14, 2021, 11:47 AM
B
I just upgraded and am getting a lot of untitled references as well!
Jan 14, 2021, 11:48 AM
C
upgraded today
Jan 14, 2021, 11:48 AM
C
so its a bug in sanity?
Jan 14, 2021, 11:48 AM
B
user Y
user M
seems something is off with the references since todays updateJan 14, 2021, 11:49 AM
B
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
B
Jan 14, 2021, 11:52 AM
C
so ill wait on a fix then?
Jan 14, 2021, 11:54 AM
B
or downgrade
Jan 14, 2021, 11:54 AM
C
whats the command to downgrade to previous version?
Jan 14, 2021, 11:54 AM
B
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
C
awesome thanks
Jan 14, 2021, 12:04 PM
M
Thanks both π we're looking into this and will release a fix asap. Sorry for the confusion, Tim!
Jan 14, 2021, 12:13 PM
C
No problem, GOOD SUPPORT!
Jan 14, 2021, 12:13 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
The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.