Upgrading to the latest version of Sanity may fix a desk crash issue when deleting a single item from a gallery.

10 replies
Last updated: Jan 5, 2022
Hello, I’m experiencing this desk crash when trying to delete a single item (clicking on the bin icon) of a gallery. I’m using a default schema:
{
  name: "gallery",
  title: "Gallery",
  type: "array",
  of: [{ type: "image" }],
},
Can’t figure out why
😕
AI Update

This sounds frustrating! While your gallery schema looks perfectly fine, Studio crashes when deleting array items (especially images) can happen for a few reasons. Let me walk you through the most common causes and solutions:

Most Common Causes:

  1. Outdated Studio version - Array handling has had several bug fixes across Studio versions. Make sure you're running the latest version of the sanity package:

    npm update sanity

    Then restart your dev server.

  2. Browser cache/state corruption - Sometimes Studio's local state gets corrupted:

    • Hard refresh (Cmd/Ctrl + Shift + R)
    • Clear browser cache and local storage for your Studio URL
    • Try in an incognito/private window
  3. Invalid metadata configuration - If you've customized your image field with metadata options, check your configuration. According to the image metadata documentation, the valid options for the options.metadata array are: image, exif, location, lqip, blurhash, and palette.

    Note that dimensions, hasAlpha, and isOpaque are always included automatically and should NOT be added to the metadata array - including them will throw an error. Make sure your schema doesn't look like this:

    // ❌ INCORRECT - will cause errors
    {
      name: "gallery",
      type: "array",
      of: [{
        type: "image",
        options: {
          metadata: ['dimensions', 'isOpaque'] // Don't do this!
        }
      }]
    }
  4. Plugin conflicts - If you have custom plugins or older third-party plugins, they may not handle array mutations properly. Try temporarily disabling plugins to isolate the issue.

Debugging Steps:

  1. Open your browser console (F12) when the crash happens - look for error messages or stack traces
  2. Check your terminal where Studio is running for server-side errors
  3. Create a minimal test document with just that gallery field to see if it's schema-specific

Temporary Workaround:

Instead of using the bin icon, try:

  • Click "Edit" on the array item, then use the item menu to delete
  • Use the array's three-dot menu to manage items
  • Manually edit the document JSON in Vision plugin as a last resort

If none of this helps, the browser console error message will be crucial for diagnosing the issue. Post it in the Sanity Slack community or search GitHub issues - the team is very responsive to crash reports and may have a specific fix for your Studio version.

Hi User, not sure about that, this is my package.json:
"dependencies": {
    "@sanity/base": "^2.9.1",
    "@sanity/components": "^2.2.6",
    "@sanity/core": "^2.10.0",
    "@sanity/dashboard": "^2.7.0",
    "@sanity/default-layout": "^2.9.1",
    "@sanity/default-login": "^2.8.0",
    "@sanity/desk-tool": "^1.149.19",
    "@sanity/vision": "^2.9.0",
    "prop-types": "^15.7",
    "react": "^17.0",
    "react-dom": "^17.0",
    "sanity-plugin-vercel-deploy": "^1.1.0"
  }

Hi User, not sure about that, this is my package.json:
"dependencies": {
    "@sanity/base": "^2.9.1",
    "@sanity/components": "^2.2.6",
    "@sanity/core": "^2.10.0",
    "@sanity/dashboard": "^2.7.0",
    "@sanity/default-layout": "^2.9.1",
    "@sanity/default-login": "^2.8.0",
    "@sanity/desk-tool": "^1.149.19",
    "@sanity/vision": "^2.9.0",
    "prop-types": "^15.7",
    "react": "^17.0",
    "react-dom": "^17.0",
    "sanity-plugin-vercel-deploy": "^1.1.0"
  }

If you run
sanity versions
in the CLI, what's the output?
@sanity/cli               2.10.0 (latest: 2.23.3)
@sanity/base               2.9.1 (latest: 2.23.3)
@sanity/components         2.2.6 (latest: 2.14.0)
@sanity/core              2.10.0 (latest: 2.23.2)
@sanity/dashboard          2.7.0 (latest: 2.23.3)
@sanity/default-layout     2.9.1 (latest: 2.23.3)
@sanity/default-login      2.8.0 (latest: 2.23.2)
@sanity/desk-tool       1.149.19 (latest: 2.23.3)
@sanity/vision             2.9.0 (latest: 2.23.3)
shall I run
sanity upgrade
?
Got it. This is likely happening because the version you're on is a fair bit older. Upgrading may very well fix it! There are also some awesome new features we've rolled at that you'll get access to.
There are some major updates doing this, though. We try not to break things from previous versions, but we may have to do some debugging after your upgrade.
Got it. This is likely happening because the version you're on is a fair bit older. Upgrading may very well fix it! There are also some awesome new features we've rolled at that you'll get access to.
There are some major updates doing this, though. We try not to break things from previous versions, but we may have to do some debugging after your upgrade.
Ok! Thanks a lot for the help in the meantime. I’ll try to update and see what happens!
I have several dependencies issues but everything seems to work just fine after the upgrade, thanks for your help User!
You're welcome!

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?