DocumentTypeList Error - ID is Required for Document Nodes

1 replies
Last updated: Jun 16, 2022
I'm getting the attached error
id is required for document nodes
when I click on the panel icon in a document (see picture for context).Looking at the
doc suggested in the error and adding an
id("some-id")
call after
.schemaType('Accomodation')
breaks the access to the documents' data when I click them in the documentTypeList (I get a form for an unpublished/new document instead of the previously saved data).The plugin I'm using for the content of the panel is "sanity-plugin-documents-pane" the problem might come from somewhere else.
My deskstructure.js looks like this:

export default () =>
  S.list()
    .title('Bala')
    .items([
// ... cut out some more items from the array. The problem is Isolated within the following item:
      S.documentTypeListItem('Accomodation')
        .title('營位預訂')
        .icon(GiCampingTent)
        .child(
          S.documentTypeList('Accomodation')
            .defaultLayout('detail')
            .child(
              S.document()
                .schemaType('Accomodation')
// adding a ".id('whatever-id')" here will make the error disappear but prevent me to edit previously saved data, instead a form for a
// new document is seen when want to edit a document. Is it the wrong place?
                .views([
                  S.view.form(),
                  S.view.component(DocumentsPane)
                    .options({
                      query: `*[!(_id in path("drafts.**")) && references($id)]`,
                      params: { id: `_id` },
                      useDraft: false
                    })
                    .title('Incoming References')
                ])
                ,
            )
        ),
    ])
I've tested on versions
2.29.5
and
2.30.1
(latest) with same results.
Jun 16, 2022, 11:11 AM
Fixed exporting a
getDefaultDocumentNode
function and putting the DocumentsPane code there. Example available in this Github issue: https://github.com/SimeonGriggs/sanity-plugin-documents-pane/issues/5
Jun 16, 2022, 12:06 PM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.