Repository navigation
Media editor: Pass mediaType to frames instead of isImage - #87871
Conversation
`renderFrame` and the frame context now carry the media type, or `null` until the media loads, so frames can tell every type apart. The route's narrow History bar checks `mediaType === 'image'`.
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +14 B (0%) Total Size: 8.73 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Navigates the items list via UP/DOWN arrow keys in
|
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the mediaType frame-prop update.
No open issues 🎉
What changed in this PR
Updates media editor frames to receive mediaType instead of isImage, allowing frames to distinguish media types.
Changes:
- Passes
mediaTypethrough frame props and context, usingnullwhile loading. - Updates image-only controls and the modal test mock to use the new property.
| File | Description |
|---|---|
| routes/media-editor/stage.tsx | Uses mediaType to show the narrow image History bar. |
| packages/media-editor/src/components/media-editor/index.tsx | Replaces frame isImage with mediaType and updates conditional controls. |
| packages/media-editor/src/components/media-editor-modal/test/index.browser.test.tsx | Updates mocked frame props to supply mediaType. |
Review effort: Balanced
andrewserong
left a comment
There was a problem hiding this comment.
Code change looks good, and it's smoke testing well for me.
Thanks for the follow-ups! 🚀
| * The type of the media being edited, or `null` until it loads. The | ||
| * history and transform clusters render nothing unless it is `image`, so a | ||
| * frame uses this to decide whether the container it would put them in is | ||
| * worth rendering at all. |
There was a problem hiding this comment.
"Clusters" reads like a breakfast cereal. I'm going to do a doc's pass on all this next.
| * The type of the media being edited, or `null` until it loads. The | |
| * history and transform clusters render nothing unless it is `image`, so a | |
| * frame uses this to decide whether the container it would put them in is | |
| * worth rendering at all. | |
| * The type of the media being edited, or `null` until it loads. | |
| * `MediaEditor.HistoryActions` (Reset, Undo, Redo) renders nothing unless | |
| * it is `image`, so a frame can skip the container it would put them in. |
There was a problem hiding this comment.
Actually, just /** The type of the media being edited, or null until it loads. */ is better.
|
Thanks for the quick reviews, folks! |
What?
Follow-up to #84664, from this review comment.
renderFrameand the frame context passmediaType(image,video,audioorapplication) instead ofisImage.It is
nulluntil the media loads, whereisImagewasfalse.The media editor route reads it for its narrow History bar.
Why?
isImageis narrow and superfluous. With the type, a frame can tell every media type apart. 👍🏻Testing Instructions
smallbreakpoint. The History bar shows under the canvas.