Issue with custom deskStructure causing Studio to lose track of path
6 replies
Last updated: Nov 30, 2021
P
Hi, I have a weird issue where the studio seems to loose track of the “path” I’m in.
I’m using a custom deskStructure to allow for multilingual content and this weird jump happens whenever I’m creating a new document (see video):
(Please also see structure in comment)
I’m using a custom deskStructure to allow for multilingual content and this weird jump happens whenever I’m creating a new document (see video):
(Please also see structure in comment)
Nov 29, 2021, 7:02 PM
P
Here’s the relevant part of the structure:
["documentReference", "documentPerson"].map((doc) => S.documentTypeListItem(doc) .title(doc.replace("document", "")) .id(doc) .child(() => S.list() .title("Locales") .id("locale") .items([ ...locales.map(({ title, code, emoji }) => S.documentTypeListItem(doc) .id(code) .title(title) .icon(renderEmoji(emoji)) .child( S.documentTypeList(doc) .id("id") .title(`${doc.replace("document", "")} (${title})`) .filter(`_type == "${doc}" && i18n.locale == "${code}"`) .child( S.document() .schemaType(doc) .views([S.view.form(), ...preview]) ) ) ), S.divider(), S.documentTypeListItem(doc) .title("Undefined") .icon(renderEmoji("❔")) .child( S.documentTypeList(doc) .id("id") .filter(`_type == "${doc}" && !defined(i18n.locale)`) .child( S.document() .schemaType(doc) .views([S.view.form(), ...preview]) ) ), ]) ) );
localesis an array of locales I’ve defined in a config file:
"locales": [ { "title": "English", "code": "en", "emoji": "🇬🇧" }, { "title": "Deutsch", "code": "de", "emoji": "🇩🇪" } ]
Nov 29, 2021, 7:05 PM
P
Was running 2.22.0, now upgraded to the most current (2.22.2)
Nov 30, 2021, 9:45 AM
P
Possibly related to https://github.com/sanity-io/sanity/issues/2140 and https://github.com/sanity-io/sanity/issues/1693
Nov 30, 2021, 12:30 PM
I believe those issues were resolved with a release last week that changed how intent resolvers were handled. Can you try adding an intent handler to your structure? It would look something like this:
S.listItem() .title('Title') .schemaType(<schema-type>) .child(() => S.documentList() .schemaType(<schema-type>) .title('Title') .canHandleIntent(() => S.documentTypeList(<schema-type>).getCanHandleIntent()) .child( //child ) ),
Nov 30, 2021, 5:56 PM
P
Great, this seems to work! Thanks a lot
Nov 30, 2021, 6:05 PM
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.