sanity-io / orderable-document-list

Drag-and-drop Document Ordering without leaving the Editing surface
MIT License
73 stars 22 forks source link

Desk tool crashes for orderable document #55

Open Jensderond opened 1 year ago

Jensderond commented 1 year ago

I get the following error when opening the item that uses orderable-document-list

Error: Could not find source context

            orderableDocumentListDeskItem({
              title: 'Properties',
              icon: MdHome,
              type: 'property',
              child: S.documentTypeList('property').title('Properties'),
              S,
              context
            }),

property:

export default {
  name: 'property',
  type: 'document',
  title: 'Properties',
  fields: [
    orderRankField({ type: "number" }),
    ...

Using versions: sanity: 3.2.6 @sanity/orderable-document-list: 1.0.2

SimeonGriggs commented 1 year ago

Are you passing S and context in from the structure function?

Jensderond commented 1 year ago

I do believe so, here's my config

sanity.config.js

  plugins: [
    deskTool({
      structure: (S, context) => {
        return S.list()
          .title('Site')
          .items([
            orderableDocumentListDeskItem({
              title: 'Properties',
              icon: MdHome,
              type: 'property',
              child: S.documentTypeList('property').title('Properties'),
              S,
              context
            }),
          ])
        }
    }),
  ]
eglove commented 1 year ago

I had this issue with sanity 3.4.0. Updating to 3.5.0 seems to have resolved itself.

Oskar-Andersson commented 6 months ago

I have this exact issue, after following tutorial / docs and integrating in my simple site, when I click the list in the deskTool I get the same error - while using a newer stack than eglove commented about. The only thing I am afraid of is that it is somehow related to me running Next.js and sanity using next-sanity. Most of these libraries are up to date at the time of writing:

"@sanity/dashboard": "^3.1.6",
"@sanity/orderable-document-list": "^1.2.1",
"@sanity/vision": "^3.29.1",
"next": "14.1.0",
"next-sanity": "^8.0.0",
"sanity": "^3.29.1"

image

I should also add that the admin (deskTool) starts with Hydration errors. But it starts - its only when I click the document list in question that the "Error: Could not find source context" appears.