Discussion about reloading issue when clicking on mixed reference links in Sanity Studio

13 replies
Last updated: Apr 27, 2021
Here's something I just noticed (still on v.2.8.1): when clicking on đź”— from an array field consisting of multiple (mixed) reference types, the whole studio app is being reloaded completely (Connecting to Sanity ...) whereas clicking on such a link from non-mixed references the app goes there gracefully as expected. The link icon is shown differently too: it's smaller for the directly linked references.
AI Update

I understand the behavior you're seeing in Studio v2.8.1, but I need to be honest: I can't find documentation confirming this is a known bug or explaining why mixed reference arrays would cause full studio reloads versus graceful navigation with single-type references.

That said, Studio v2.8.1 is quite outdated—Studio v2 reached end of life on April 1st, 2024, meaning it no longer receives bug fixes or security patches. The version you're on was released years before v2 support ended, so there are likely many unresolved issues.

What I'd recommend:

The most reliable path forward is upgrading to the current version of Sanity Studio. Studio v3 (and now v4) brought fundamental architectural changes including:

  • Completely rewritten navigation and intent system
  • Modern build tooling with Vite
  • Full TypeScript support with better type inference
  • A new plugin API that replaced the old Parts System

These architectural improvements likely address navigation issues like what you're experiencing, though I can't point to a specific bug fix for this exact scenario.

Regarding your mixed reference array:

The syntax for arrays with multiple reference types should look like:

{
  name: 'myArray',
  type: 'array',
  of: [
    { type: 'reference', to: [{ type: 'youTube' }] },
    { type: 'reference', to: [{ type: 'blogPost' }] }
  ]
}

This is valid in both v2 and v3+, so the schema itself shouldn't be causing issues—it's more likely a navigation bug in that older Studio version.

If you can't upgrade immediately:

Try opening your browser's developer console when clicking those links to see if there are any JavaScript errors that might give more insight into what's failing. But given that v2 is no longer supported, any workarounds would be temporary at best.

The different link icon sizes you're seeing might be a visual indicator of how the Studio is resolving those references, but without access to v2 source code or documentation about that specific behavior, I can't say definitively what causes it. This discrepancy between how single-type and mixed-type reference arrays handle navigation suggests the Studio's intent resolution system in v2 had different code paths for these scenarios, and the mixed-type path appears to trigger a full reload rather than using the internal router.

It appears that the untyped links perform a lookup of the type (mapping the _id to the correct _type), then perform a redirect to the edit page. Because it fully reloads the app, it feels a bit abrupt.
There was a regression where it was temporarily possible to reference draft documents, which would give these link issues. Could you try upgrading to the latest version of the studio and check if any refs to drafts exist? If so, it'd be good to correct them.
I don't think this is it, I am not referencing any drafts.
Could you share how you've implemented the mixed reference field? Also, is it using any custom components?
The link href is:
/intent/edit/id=89f42315-a5f8-4e58-83cc-c9f24c0386d7/
- compared to
/intent/edit/id=7c191231-3dae-4c88-8126-24f696f85437;type=propertyType/
for non-mixed (and honestly, non-array type). As you can see, the type is already set here.
That's correct - intent links need a type indeed, so that would explain the reloading at least 🙂 I've seen the same behaviour on a project that was on a lower version, where it disappeared after an upgrade. Did you try upgrading to
v2.9.1
to see if it resolves the issue?
That's correct - intent links need a type indeed, so that would explain the reloading at least 🙂 I've seen the same behaviour on a project that was on a lower version, where it disappeared after an upgrade. Did you try upgrading to
v2.9.1
to see if it resolves the issue?
I will try to upgrade now
user M
that worked! I should have upgraded sooner, but I thought to hold off seeing some other regressions popping up here.
Even the đź”— icons are nice and consistent now! Thanks!
Apologies for the regression - we had an unforeseen issue with the search update that we had to revert as a result. We're working on a fix, but the latest version is stable as far as I've seen 🙂
Indeed they are! The components team migrated reference inputs to Sanity UI
✨
Apologies for the regression - we had an unforeseen issue with the search update that we had to revert as a result. We're working on a fix, but the latest version is stable as far as I've seen 🙂
Indeed they are! The components team migrated reference inputs to Sanity UI
✨

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?