Skip to content

fix: shim missing helper so live-preview click-to-edit works in production#134

Open
PaulBratslavsky wants to merge 1 commit into
strapi:mainfrom
PaulBratslavsky:fix/live-preview-helper-shim
Open

fix: shim missing helper so live-preview click-to-edit works in production#134
PaulBratslavsky wants to merge 1 commit into
strapi:mainfrom
PaulBratslavsky:fix/live-preview-helper-shim

Conversation

@PaulBratslavsky

Copy link
Copy Markdown
Collaborator

Summary

Live-preview click-to-edit silently breaks in production (works fine under strapi develop). The rendered preview loads, but hovering/clicking text or media never highlights or selects a field.

Root cause

Strapi's production admin build injects a live-preview highlight script into the preview iframe. That script calls a minified bundler helper — a lazy-import wrapper around import('@vercel/stega') — but never includes the helper in the emitted script string:

const { vercelStegaDecode, vercelStegaClean } = await ye(async () => {
  const { vercelStegaDecode, vercelStegaClean } =
    await import("https://cdn.jsdelivr.net/npm/@vercel/stega@.../+esm");
  return { vercelStegaDecode, vercelStegaClean };
}, []);

ye is undefined at runtime → ReferenceError: ye is not defined. The script's init promise rejects with no .catch, so the entire highlight/click system never initializes (no overlay, no data-strapi-source tagging, no field selection). It works in dev because the dev build inlines the helper.

The minified name is not stable — it changes between Strapi builds (observed yebe), so it can't be hardcoded.

⚠️ This is a workaround — the real fix belongs in Strapi core

This PR is a temporary client-side shim to unblock click-to-edit. The actual bug is in Strapi's admin build (it emits a script referencing a helper it doesn't bundle). A separate issue/PR should be filed against strapi/strapi so the injected preview script is self-contained. Once Strapi ships that fix, this shim should be removed.

  • File upstream Strapi issue/PR for the self-contained preview script
  • Remove this shim once Strapi is fixed

What this PR does

In Preview, before injecting Strapi's script, parse every await NAME(async …) helper out of the script text and define each as a passthrough that runs the factory. Helpers the script defines locally simply shadow these globals, so it's safe and name-agnostic (handles ye, be, and any future rename).

Validation

Verified end-to-end against the production Strapi admin build (helper be) via Playwright, driving the real admin preview iframe:

data-strapi-source els .strapi-highlight els overlay click → admin
Before 6 0
After 50 34 strapiFieldSingleClickHint

Reproduces on Strapi 5.47.1. Affects production deployments only.

🤖 Generated with Claude Code

…ction

Workaround for a Strapi core bug — root cause should be fixed upstream in Strapi.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

@PaulBratslavsky is attempting to deploy a commit to the Strapi-Website Team on Vercel.

A member of the Team first needs to authorize it.

@PaulBratslavsky

Copy link
Copy Markdown
Collaborator Author

Update: root cause fixed upstream in Strapi

The underlying bug is fixed at the source in strapi/strapi#26732 — it makes the injected live-preview highlight script self-contained, so it no longer references an unbundled minified helper (ye/be/…).

Verified against the experimental build 0.0.0-experimental.5281af240fc8ba10a5a2e34b9593ac192d11fa4f (production build, no shim):

Broken (5.47.1) With #26732
injected script references undefined helper self-contained (await NAME(async…) pattern gone)
data-strapi-source els 6 50
.strapi-highlight els 0 34
overlay
click → admin strapiFieldSingleClickHint
ReferenceError ye/be is not defined none

Recommendation

  • Once #26732 ships in a stable Strapi release that LaunchPad depends on, this shim can be removed (revert preview.tsx to the plain script injection).
  • Until then, this shim is still useful for anyone on Strapi ≤ the affected versions, since stable releases don't yet contain the fix.

Leaving open for maintainers to decide whether to merge as an interim workaround or close in favor of bumping Strapi once the fix is in a stable release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant