✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

Issue with popup overlay flashing and reloading in production, fixed in latest release.

7 replies
Last updated: Mar 22, 2024
Hi y’all. I have a weird issue that’s only happening in production. I have an embedded studio inside a Next.js app hosted on Vercel. Whenever a field uses a popup overlay for input, like an array, the overlay flashes and reloads on every background save. I attached a couple videos showing what I am describing. The first video is the production version, the second is the same version running locally. It’s extremely annoying, and each time it reloads the focus resets, so if you happen to be typing when it happens your text gets messed up. Really hurting the overall usability of the studio. Anyone ever run into anything like this? I am using Sanity 3.35.0, Next 14.1, and next-sanity 8.4.5.
Mar 21, 2024, 7:03 PM
Can you share your code for the page that this is embedded in?
Mar 21, 2024, 9:43 PM
I have the studio embedded at app/[[…index]], here is that page.tsx file:
import {Studio} from './Studio'

// Ensures the Studio route is statically generated
export const dynamic = 'force-static'

// Set the right `viewport`, `robots` and `referer` meta tags
export {metadata} from 'next-sanity/studio/metadata'
export {viewport} from 'next-sanity/studio/viewport'

export default function StudioPage() {
  return <Studio />
}

Mar 22, 2024, 4:49 PM
And the Studio component that is imported:
'use client'

import {NextStudio} from 'next-sanity/studio'

import _config from '../../sanity.config'
import {useEffect, useState} from 'react'

export function Studio() {
  const [config, setConfig] = useState(_config)

  useEffect(
    // Start fetching the theme in parallel with the Studio auth loading
    () =>
      // The webpackIgnore tells webpack to not attempt bundling this dynamic import,
      // and instead let it run natively in the browser at runtime
      void import(/* webpackIgnore: true */ '<https://themer.sanity.build/api/hues?preset=dew').then(>
        ({theme}) => setConfig((config) => ({...config, theme})),
      ),
    [],
  )

  //  Supports the same props as `import {Studio} from 'sanity'`, `config` is required
  return <NextStudio config={config} />
}
Mar 22, 2024, 4:50 PM
I believe this got fixed in a release yesterday! Can you upgrade to see if it was addressed?
Mar 22, 2024, 5:19 PM
You bet! Is the fix in sanity or next-sanity?
Mar 22, 2024, 5:20 PM
Sanity!
Mar 22, 2024, 5:26 PM
That fixed it, thank you so much!
Mar 22, 2024, 5:30 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?