Skip to content

fix(admin): align image upload placeholders and spinners across the admin - #3609

Merged
ascorbic merged 4 commits into
mainfrom
noah/editor-media/upload-consistency
Sep 29, 2026
Merged

ascorbic merged 4 commits into
mainfrom
noah/editor-media/upload-consistency

Conversation

@khoinguyenpham04

@khoinguyenpham04 khoinguyenpham04 commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

This is a follow-up to #3594 that brings the editor's image upload placeholder in line with the rest of the admin.

  1. Broken preview in the editor. The Portable Text editor previewed every image/* file while it uploaded. Formats the browser can't display, such as HEIC and TIFF, showed a broken-image icon. The Media Library upload list already had a rule for this: previews only for files up to 8 MB in JPEG, PNG, GIF, WebP or AVIF. That rule moves unchanged from MediaUploadDialog.tsx to lib/media-utils.ts as createUploadPreviewUrl, and both the library and the editor now use it. Other files upload with a plain "Uploading image…" placeholder.
  2. Different wording for the same rejection. The editor says "Only image files can be uploaded here." while the featured and Open Graph image drop fields said "…dropped here." Both now use the editor's wording, which is also accurate for paste. The new string is already in the extracted catalogs; messages.po is untouched.
  3. Kumo's Loader instead of a copied spinner. The placeholder is a ProseMirror widget built from plain DOM, so it carried a hand-copied version of the Loader's SVG. It now mounts Kumo's <Loader size="sm" /> in a small React root, which unmounts when the widget is destroyed. The spinner sits inside an aria-hidden wrapper, because Loader always renders role="status" and ignores props it doesn't declare, so "Uploading image…" stays the single announced status.
  4. Full-width placeholder when there's no preview. Placeholders shrink to fit their preview image. Without one, which applies to the formats from item 1 and to the "Only image files…" card, they collapsed to their 288px minimum. They now span the column, like the images they become.
  5. No extra "Loading" announcement in the featured and Open Graph image fields. ImageDropTarget passed aria-hidden to Loader, which drops it, so screen readers heard "Loading" beside the "Uploading image…" status. The spinner now sits in an aria-hidden wrapper, the same pattern as item 3.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes (admin package; the only package changed)
  • pnpm lint passes (lint:quick and type-aware lint:json both report 0 diagnostics)
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added and reviewed the user-facing changeset (if this PR changes a published package)
  • New features link to an approved Discussion: n/a, bug fix
  • I have included screenshots below if this PR changes the UI

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 5.5 (Claude Code), reviewed adversarially by a separate Claude Opus session

Screenshots / test output

A HEIC photo dropped into the editor now uploads with a plain, full-width placeholder and Kumo's spinner. Before this change, the same spot showed a broken-image icon in a 288px box:

Portable Text editor with a full-width grey "Uploading image…" placeholder and spinner between two paragraphs, with no broken image

A PNG and a PDF dropped together. The PNG shows its preview while it uploads, and the PDF gets the aligned rejection message at full width:

Portable Text editor showing a faded sunset preview with an "Uploading image…" pill, followed by a full-width card reading "Only image files can be uploaded here." with a Dismiss button

Test output (packages/admin vitest, browser):

  • tests/editor/image-upload.test.tsx adds two tests, each confirmed failing first:
    • "uploads images the browser can't display without a broken preview". Before the fix, the HEIC drop rendered a blob <img>.
    • "shows a spinner hidden from screen readers and unmounts it with the placeholder". The only announced status is "Uploading image…", and the spinner's React root is unmounted once the image is inserted.
  • tests/components/ImageDropTargets.test.tsx is updated for the aligned message. It also adds "announces only the upload status while featured/og uploads", which failed before the fix: the announced statuses were ['', 'Uploading image…'].
  • The MediaUploadDialog, useMediaUploadQueue, MediaLibrary and PortableTextEditor suites also pass.
  • Playwright: e2e/tests/portable-text-image-upload.spec.ts passes 3/3 against the rebuilt admin. A real-browser run logged no React errors or warnings.

…ss uploads

Images the browser can't display (HEIC, TIFF) or larger than 8 MB no
longer show a broken preview while uploading in the Portable Text editor;
the editor now uses the Media Library's preview rule, moved to
lib/media-utils. The featured and Open Graph image drop fields use the
same image-only message as the editor.
@changeset-bot

changeset-bot Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b01753c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@emdash-cms/admin Patch
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/plugin-test Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
create-emdash Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://noah-editor-media-upload-consistency.try.emdashcms.com, https://noah-editor-media-upload-consistency-emdash-playground.emdash-cms.workers.dev (commit b01753c)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://cee8df79.try.emdashcms.com, https://cee8df79-emdash-playground.emdash-cms.workers.dev b01753c 2026-09-29T10:01:48.252Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://90e1ded6.try.emdashcms.com, https://90e1ded6-emdash-playground.emdash-cms.workers.dev 2485a8f 2026-09-29T09:48:27.299Z Visit the dashboard ↗

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary

This is the right change for the follow-up described in PR #3594. Centralizing the upload-preview rule in lib/media-utils.ts fixes a real, user-visible inconsistency (HEIC/TIFF files rendering a broken-image icon in the Portable Text editor while uploading) and keeps the Media Library and editor behavior in sync without expanding scope.

I read every changed hunk, the helper file, both call sites, useMediaUploadQueue's object-URL lifecycle, the changeset against .changeset/README.md, and searched the admin package for other upload-preview paths. Things look clean:

  • createUploadPreviewUrl is the correct extraction: it preserves the existing 8 MB / JPEG-PNG-GIF-WebP-AVIF rule, returns undefined for everything else, and safely swallows URL.createObjectURL failures.
  • Both callers handle undefined preview URLs correctly. ImageUploadExtension only tracks a blob URL when one is created, and releasePreview/onDestroy still revoke every created URL. useMediaUploadQueue checks job.previewUrl before revoking on unmount, cancel, clear, and reset, and accepts undefined from the new helper.
  • The aligned rejection message "Only image files can be uploaded here." is the existing catalog string used by the editor (msg\`` macro there, t`macro inImageDropTarget), so no messages.po` churn is correct.
  • The regression tests are meaningful: the HEIC fixture asserts no <img> is rendered, and the ImageDropTargets test verifies the updated wording.
  • The changeset is user-facing, names the affected package, and explains the observable bug and the fix without veering into internals.

No logic bugs, regressions, security issues, or AGENTS.md convention violations found. LGTM.

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Sep 29, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@3609

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@3609

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@3609

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@3609

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@3609

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@3609

emdash

npm i https://pkg.pr.new/emdash@3609

create-emdash

npm i https://pkg.pr.new/create-emdash@3609

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@3609

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@3609

@emdash-cms/plugin-test

npm i https://pkg.pr.new/@emdash-cms/plugin-test@3609

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@3609

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@3609

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@3609

@emdash-cms/registry-loader

npm i https://pkg.pr.new/@emdash-cms/registry-loader@3609

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/@emdash-cms/registry-moderation@3609

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@3609

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@3609

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@3609

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@3609

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@3609

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@3609

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@3609

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@3609

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@3609

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@3609

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@3609

commit: b01753c

The placeholder is a ProseMirror widget built from plain DOM, so it carried
a copy of the Loader's SVG. It now mounts the Kumo component in a React
root that unmounts when the widget is destroyed.
Kumo's Loader always renders role="status" and ignores aria-hidden, so
featured and Open Graph uploads announced an extra "Loading" beside the
"Uploading image…" status. Wrap it in an aria-hidden span, as the editor
placeholder does.
@khoinguyenpham04 khoinguyenpham04 changed the title fix(admin): share the upload preview rule and image-only message across uploads fix(admin): align image upload placeholders and spinners across the admin Sep 29, 2026
@github-actions github-actions Bot added review/needs-rereview New commits since the last review and removed review/approved Approved; no new commits since labels Sep 29, 2026
@ascorbic
ascorbic merged commit fc019e4 into main Sep 29, 2026
41 checks passed
@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-rereview New commits since the last review labels Sep 29, 2026
@ascorbic
ascorbic deleted the noah/editor-media/upload-consistency branch September 29, 2026 12:09
@emdashbot emdashbot Bot mentioned this pull request Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants