Skip to content

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

10repliesLast updated: Nov 13, 2026

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

A link popover in the Portable Text editor that closes or flickers when you click into it is most likely a Studio bug, not a mistake in your setup. Upgrading the sanity package to the latest release usually fixes it. If it still happens after upgrading, change the link annotation's href field from url to string, or create links by pasting.

1. Upgrade the Studio

Studio is the sanity npm package, and releases ship up to weekly. Install the latest release instead of using npm update, which stays inside the version range in your package.json:

npm install sanity@latest
npx sanity versions
npx sanity dev

npx sanity versions shows whether every Sanity package is current. Update related packages such as @sanity/vision the same way. If the upgrade crosses a major version (v3 → v4 → v5 → v6), read each migration guide first. Studio v4 and later needs Node.js v20.19 or newer. See Upgrading Sanity Studio. After that, redeploy with npx sanity deploy, or push to the branch that deploys your Studio.

2. If it still happens: use string for href

The standard external-link annotation uses a url field (guide):

marks: {
  annotations: [
    {
      name: 'link',
      type: 'object',
      title: 'External link',
      fields: [
        { name: 'href', type: 'url', title: 'URL' },
        { name: 'blank', type: 'boolean', title: 'Open in new tab' },
      ],
    },
  ],
}

The url type renders a browser input with type="url" and always runs uri() validation, which allows only http and https by default (URL type). If that input misbehaves inside the popover, use a plain string field instead. It saves the same kind of value (a string), so your front-end rendering doesn't change:

{ name: 'href', type: 'string', title: 'URL' }

If you keep url, you can change what it accepts with your own uri() rule, which replaces the default. For example, rule.uri({scheme: ['http', 'https', 'mailto', 'tel']}) adds more schemes. allowRelative: true allows relative paths and also switches the input to type="text", so the browser stops checking the URL.

3. Shortcut: paste a URL onto selected text

By default, the Portable Text editor turns pasted links into annotations: select some text and paste a URL. This looks for an annotation named link with an href field, which matches the schema above. You don't need to type in the popover at all. If your annotation has a different name, you can write a custom matcher with pasteLink.link(...) (Portable Text editor configuration).

Third-party cookie warnings and "websocket closed before handshake" errors are separate from the popover problem. If the popover still fails on the latest version, open the browser console while you add a link and copy any errors. Search or report them on the sanity-io/sanity GitHub issues, with your browser and the output of npx sanity versions.

Show original thread
10 replies

Was this answer helpful?

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.

Related contributions