🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Issue with custom deskStructure causing Studio to lose track of path

6 replies
Last updated: Nov 30, 2021
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)
Nov 29, 2021, 7:02 PM
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])
                  )
              ),
          ])
      )
  );

locales
is 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
What version of the Studio are you running?
Nov 29, 2021, 9:34 PM
Was running 2.22.0, now upgraded to the most current (2.22.2)
Nov 30, 2021, 9:45 AM
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
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.

Was this answer helpful?