hierarchical-document-list icon indicating copy to clipboard operation
hierarchical-document-list copied to clipboard

Issue with creatableTypes Configuration in sanity3 Plugin

Open lhoucinecherif opened this issue 1 year ago • 0 comments

Describe the bug

I am experiencing an issue with the sanity3 plugin, specifically with the creatableTypes configuration in the createDeskHierarchy function. I want to prevent the "home" document type from being creatable, but the configuration does not seem to work as expected.

To Reproduce

Here is the configuration I am using:

const siteHierarchy = createDeskHierarchy({
  S,
  context,
  title: 'Site Structure',
  documentId: 'site-structure',
  referenceTo: ['home', 'page', 'project'],
  referenceOptions: {
    // Optional filters
  },
  icon: SchemaIcon,
  maxDept: 3,
  creatableTypes: ['page', 'project'] // 'home' is excluded
});

Expected behavior

The "home" document type should not be creatable within the hierarchy.

Actual Behavior:

Despite excluding "home" from the creatableTypes array, it is still possible to create documents of this type.

Steps to Reproduce:

1 - Configure the createDeskHierarchy as shown above. 2 - Attempt to create a new document within the hierarchy. 3 - Observe that the "home" document type is still creatable.

Which versions of Sanity are you using?

@sanity/cli (global) 3.52.0 (latest: 3.57.3) @sanity/code-input 4.1.4 (up to date) @sanity/color-input 3.1.1 (latest: 4.0.1) @sanity/eslint-config-studio 3.0.1 (latest: 4.0.0) @sanity/hierarchical-document-list 2.0.0 (up to date) @sanity/icons 3.3.1 (latest: 3.4.0) @sanity/vision 3.54.0 (latest: 3.57.3) sanity 3.54.0 (latest: 3.57.3)

What operating system are you using?

Distributor ID: Ubuntu Description: Ubuntu 22.04.4 LTS Release: 22.04 Codename: jammy

Which versions of Node.js / npm are you running?

NPM 10.8.1 Node v20.15.0

Additional Context:

The "home" document type is configured as a singleton. This might be affecting the behavior of the creatableTypes configuration.

lhoucinecherif avatar Sep 17 '24 09:09 lhoucinecherif