Sanity Studio rich text link URL input closes/flickers when clicked

10 replies
Last updated: Apr 18, 2024
Hey Everyone! New to Sanity, so I hope this isn't a stupid question. Has anyone encountered an issue where I want to add an external link URL in a rich text field inside the Sanity studio, but the box which asks for entering the URL just closes when I click inside it? When I click the edit link pencil icon it just flickers (disappears and then appears again). After much trial and error across many browsers I finally managed to insert a link by accessing the studio in chrome on a mobile device - but that still required dozens of attempts to write inside the field, and it's a pain in the... I don't understand the problem beyond it complaining about 3rd party cookies (even when they're enabled) and websocket closing before a handshake. Does this work normally for y'all or is it a known issue? I feel like I'm the only idiot in the room, but otherwise I set up everything correctly, even the portableText configuration for rendering inside the Next.js app. But since this happens inside the studio I didn't know where else to look since I don't understand any of the code there.
AI Update

This is definitely not a stupid question - what you're describing sounds incredibly frustrating, and I want to help you get to the bottom of it!

First, let me be upfront: the specific issue you're experiencing (popover closing when clicking inside the URL field, flickering edit icon) isn't something I can find documented as a known issue in Sanity's official documentation. However, the symptoms you're describing - especially the third-party cookie warnings and websocket errors - point to some likely culprits.

What Could Be Happening

The fact that you're seeing third-party cookie warnings and websocket closing before handshake errors is significant. These suggest that something in your browser environment is interfering with how Sanity Studio communicates with Sanity's backend services. The Studio needs to maintain connections to Sanity's APIs for real-time features and authentication, and restrictive browser settings can break these connections in unexpected ways.

The popover closing immediately when you try to interact with it could be a symptom of these connection issues causing focus/state management problems in the Studio UI.

Things to Try

1. Browser Privacy Settings

Since you mentioned third-party cookies specifically, start here:

  • Enable third-party cookies for your Studio domain and sanity.io domains
  • Disable strict tracking protection for your Studio URL (in Firefox: click the shield icon; in Safari: disable "Prevent Cross-Site Tracking" for the site; in Brave: turn off Shields)
  • Try Chrome if you're not already using it - Chrome tends to have fewer issues with Sanity Studio than browsers with aggressive privacy defaults like Safari or Firefox

2. Browser Extensions

Ad blockers and privacy extensions can interfere with Studio functionality:

  • Test in an incognito/private window with all extensions disabled
  • Specifically check for uBlock Origin, Privacy Badger, Ghostery, or similar extensions
  • Try a completely fresh browser profile

3. Network Environment

The websocket errors suggest potential network-level blocking:

  • Are you behind a corporate firewall, VPN, or proxy? These can block websocket connections
  • Try on a different network (like your phone's hotspot) to rule out network restrictions
  • Check if your network admin needs to allowlist Sanity's domains

4. Keyboard Navigation Workaround

While troubleshooting, try this alternative approach:

  • Select the text you want to link
  • Click the link icon
  • Instead of clicking in the URL field, press Tab to navigate to it
  • Type or paste your URL
  • Press Enter to confirm

This sometimes bypasses focus management issues that clicking triggers.

5. Update Sanity Studio

Make sure you're running the latest version:

npm update sanity

If you're on Studio v4, ensure you're using Node.js 20+ as that's a requirement.

6. Clear Cache and Restart

Sometimes corrupted browser state causes UI issues:

  • Clear your browser cache for the Studio URL
  • Restart your development server (npm run dev)

Your Schema Is Probably Fine

Since you mentioned that portable text rendering works correctly in your Next.js app, your schema configuration is almost certainly correct. The Block Content structure you've set up is working - this is purely a Studio UI interaction issue, not a configuration problem.

Next Steps If Nothing Works

If you've tried all the above without success:

  1. Check browser console - Open your browser's developer tools (F12) and look at the Console and Network tabs when you try to add a link. Share any error messages you see.

  2. Try the production Studio - If you're developing locally, try accessing your Studio through yourproject.sanity.studio to see if the issue persists in the hosted environment.

  3. Report it - Search Sanity's GitHub issues to see if others have reported similar behavior, or post in the Sanity Slack community with:

    • Your browser and version
    • Your Sanity Studio version (npm list sanity)
    • Any console errors
    • Whether it happens in multiple browsers

The fact that it eventually worked on mobile Chrome (even if painfully) strongly suggests this is a browser-specific issue rather than a fundamental problem with your setup. You're not an idiot - you've actually done great troubleshooting by testing across multiple browsers and finding a workaround!

Start with the browser privacy settings and extension checks - those are the most common causes of the symptoms you're describing. Good luck, and I hope you get it sorted!

Show original thread
10 replies
👋 What version of the Studio are you running?
Hi rd, thanks for replying. i'm using these versions: @sanity/cli (global) 3.36.3 (latest: 3.38.0)@sanity/cli 3.38.0 (up to date)
@sanity/eslint-config-studio 4.0.0 (up to date)
@sanity/icons 2.11.8 (up to date)
@sanity/vision 3.36.3 (latest: 3.38.0)
sanity 3.36.3 (latest: 3.38.0)
Can you try updating to the latest versions of everything to see if that fixes it?
incredible, it fixed it indeed. thanks! it's funny because i started working with Sanity about a week ago, guess that was a fresh bug or there was some conflict? works like a charm now!
Glad it was an easy fix! We do our best but bugs do indeed show up in some releases.
thanks so much, i got into building a prototype for a new website for a client using some crappy page builder, and am demonstrating the power of headless cms, and fell in love with sanity. i freaked out with this bug because i thought i'd have to tell them they couldn't use links in their content 🙂 thanks a bunch for the quick reply!
Yay! I’m glad you’re loving it!
one more thing... i messed around with it some more and ran into the same problem again, even with all the versions updated. but when i changed the URL type from url to string, it worked fine again. so if someone gets the same issue, try that as well in your schema. annotations: [ {
title: 'URL',
name: 'link',
type: 'object',
fields: [
{
title: 'URL',
name: 'href',
type: 'string', <---
},
],
},
], (...) absolutely no idea why though, but it's messing with the box for sure.
Hm, that is odd. Which browser is it happening in?
I tested in chrome, edge and firefox, as well as chrome mobile before giving up and just setting it to string type. I can probably use some regex validations if necessary, but the important thing is I found how to make it work. the rest is just a bonus 🙂 but yeah, definitely sounds like something that shouldn't happen, and I haven't found anyone else with such issues when googling. that's when I decided to try asking here. I would test it in more browsers but I don't have any others.

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?