Repository navigation
fix(admin): align image upload placeholders and spinners across the admin - #3609
Conversation
…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 detectedLatest commit: b01753c The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
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 |
🚀 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 deploymentPreview Deployments by commit
|
There was a problem hiding this comment.
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:
createUploadPreviewUrlis the correct extraction: it preserves the existing 8 MB / JPEG-PNG-GIF-WebP-AVIF rule, returnsundefinedfor everything else, and safely swallowsURL.createObjectURLfailures.- Both callers handle
undefinedpreview URLs correctly.ImageUploadExtensiononly tracks a blob URL when one is created, andreleasePreview/onDestroystill revoke every created URL.useMediaUploadQueuechecksjob.previewUrlbefore revoking on unmount, cancel, clear, and reset, and acceptsundefinedfrom 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 nomessages.po` churn is correct. - The regression tests are meaningful: the HEIC fixture asserts no
<img>is rendered, and theImageDropTargetstest 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.
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-test
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-loader
@emdash-cms/registry-moderation
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
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.
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.
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 fromMediaUploadDialog.tsxtolib/media-utils.tsascreateUploadPreviewUrl, and both the library and the editor now use it. Other files upload with a plain "Uploading image…" placeholder.messages.pois untouched.Loaderinstead 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 anaria-hiddenwrapper, becauseLoaderalways rendersrole="status"and ignores props it doesn't declare, so "Uploading image…" stays the single announced status.ImageDropTargetpassedaria-hiddentoLoader, which drops it, so screen readers heard "Loading" beside the "Uploading image…" status. The spinner now sits in anaria-hiddenwrapper, the same pattern as item 3.Type of change
Checklist
pnpm typecheckpasses (admin package; the only package changed)pnpm lintpasses (lint:quickand type-awarelint:jsonboth report 0 diagnostics)pnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain.AI-generated code disclosure
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:
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:
Test output (
packages/adminvitest, browser):tests/editor/image-upload.test.tsxadds two tests, each confirmed failing first:<img>.tests/components/ImageDropTargets.test.tsxis 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…'].MediaUploadDialog,useMediaUploadQueue,MediaLibraryandPortableTextEditorsuites also pass.e2e/tests/portable-text-image-upload.spec.tspasses 3/3 against the rebuilt admin. A real-browser run logged no React errors or warnings.