Skip to content

Media editor: Throw when a panel takes a name already in use - #87792

Merged
ramonjd merged 2 commits into
trunkfrom
update/media-editor-panel-duplicate-name-error
Dec 3, 2026
Merged

ramonjd merged 2 commits into
trunkfrom
update/media-editor-panel-duplicate-name-error

Conversation

@ramonjd

@ramonjd ramonjd commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

What?

Follow-up to #84664.

A media editor panel that takes a name already used by a mounted panel now throws an error.

  • For a plugin's panel, PluginArea catches the error and drops that plugin, and the editor shows its existing "plugin has encountered an error" notice. The panel that had the name keeps its tab.
  • Core's Crop and Details mount before PluginArea, so a plugin that reuses one of their names is the one dropped.

Nothing is exported yet, so only the tests can trigger this today.

Why?

Before, the second panel rendered nothing and took over the tab when the first one unmounted. The only sign was a warning in development, so the clash was silent in production. With no takeover, the code that tracked which panel had each name in React state is removed.

Testing Instructions

There should be no regressions.

  1. Insert an Image block, choose an image, and click "Edit image" in the block toolbar.
  2. Switch between Crop and Details, crop, edit the alt text, and save. It works as on trunk.
  3. Activate the Media Editor (Route) experiment. Upload a PDF or video. Open the editor for that PDF/video: only Details show.

A second mounted panel with the same name used to warn in development, render nothing, and take the tab when the first panel unmounted. It now throws.

For a plugin's panel, `PluginArea` catches the error and drops that plugin, and the editor shows its existing plugin error notice. The first panel keeps its tab.

With no handover to wait for, the editor no longer keeps which panel has each name in React state.
@ramonjd ramonjd added [Type] Enhancement A suggestion for improvement. [Feature] Media Anything that impacts the experience of managing media labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: -78 B (0%)

Total Size: 8.73 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 575 kB -78 B (-0.01%)

65038f7 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric bcd6dc3 trunk % Change
timeToFirstByte 36.3 ms +9.5% -5.79% 35.9 ms +18.94% -3.62% 1.11%
largestContentfulPaint 60 ms +10% -6.67% 60 ms +16.67% -0% 0%
lcpMinusTtfb 25.05 ms +3.79% -15.97% 24.55 ms +4.89% -13.44% 2.04%
wpBeforeTemplate 19.03 ms +20.18% -4.73% 18.79 ms +19.32% -1.7% 1.28%
wpTemplate 13.68 ms +5.92% -5.77% 13.72 ms +8.45% -4.3% -0.29%
wpTotal 33.16 ms +11.22% -5.88% 33.05 ms +18.91% -4.24% 0.33%
wpMemoryUsage 7.75 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric bcd6dc3 trunk % Change
timeToFirstByte 29.75 ms +7.39% -4.37% 30.75 ms +8.46% -2.6% -3.25%
largestContentfulPaint 56 ms +0% -7.14% 56 ms +7.14% -0% 0%
lcpMinusTtfb 23.9 ms +9.83% -1.46% 26.05 ms +2.3% -5.57% -8.25%
wpBeforeTemplate 16.59 ms +11.45% -2.11% 16.9 ms +2.19% -1.72% -1.83%
wpTemplate 10.06 ms +7.75% -3.68% 10.49 ms +7.15% -6.01% -4.1%
wpTotal 27.12 ms +7.82% -4.09% 27.92 ms +8.17% -3.83% -2.87%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric bcd6dc3 trunk % Change
mediaProcessingJpeg 220.64 ms +4.95% -1.04% 222.59 ms +3.03% -1.31% -0.88%
mediaProcessingAvif 3547.4 ms +1.53% -0.25% 3645.44 ms +1.01% -0.28% -2.69%
mediaProcessingJpegToAvif 2467.97 ms +1.06% -0.52% 2577.62 ms +0.92% -2.07% -4.25%

media-upload

Metric bcd6dc3 trunk % Change
jpegUploadProcessing 1447.34 ms +1.11% -2.42% 1418.3 ms +1.64% -0.33% 2.05%
pngUploadProcessing 194.09 ms +8.2% -3.84% 191.4 ms +4.75% -3.06% 1.41%
largeJpegUploadProcessing 1442.63 ms +0.92% -1.66% 1445.86 ms +0.78% -0.92% -0.22%
multipleImageUploadProcessing 1478.27 ms +3.24% -0.09% 1502.41 ms +0.79% -1.4% -1.61%

post-editor

Metric bcd6dc3 trunk % Change
serverResponse 502.06 ms +3.3% -2.11% 511.89 ms +1.66% -9.07% -1.92%
firstPaint 425.19 ms +10.06% -8.33% 452.55 ms +6.56% -12.92% -6.05%
domContentLoaded 841.82 ms +1.17% -2.45% 876.52 ms +1.73% -1.13% -3.96%
loaded 843.16 ms +1.17% -2.5% 877.76 ms +1.75% -1.15% -3.94%
firstContentfulPaint 465.9 ms +3.85% -1.89% 488.67 ms +3.6% -2.29% -4.66%
firstBlock 2326.62 ms +3.67% -1.73% 2422.83 ms +1.96% -0.57% -3.97%
type 18.45 ms +11% -13.82% 20.88 ms +3.78% -16.52% -11.64%
typeWithoutInspector 17.58 ms +7.62% -6.6% 21.32 ms +5.53% -9.15% -17.54%
typeWithTopToolbar 22.89 ms +5.02% -1.44% 25.77 ms +11.14% -4.77% -11.18%
typeContainer 8.4 ms +12.74% -2.38% 9.17 ms +15.05% -4.8% -8.4%
focus 109.82 ms +5.88% -3.31% 117.64 ms +6.52% -5.61% -6.65%
firstFocus 276.82 ms +0% -0% 310.23 ms +0% -0% -10.77%
selectAll 408.12 ms +1.48% -1.83% 454.44 ms +0.26% -0.43% -10.19%
undo 29.92 ms +5.92% -4.55% 32.31 ms +5.66% -5.01% -7.4%
listViewOpen 47.56 ms +7.55% -5.61% 40.45 ms +6.72% -2.18% 17.58%
inserterOpen 48.06 ms +1.31% -6.37% 42.64 ms +18.5% -5.98% 12.71%
inserterHover 12.78 ms +9.39% -10.8% 11.21 ms +14.99% -7.58% 14.01%
inserterSearch 9.27 ms +9.39% -6.69% 9.32 ms +7.51% -18.24% -0.54%
loadPatterns 688.42 ms +6.57% -6.16% 677.69 ms +1.81% -1.08% 1.58%
wpTotal 491.31 ms +3.08% -2.01% 501.85 ms +1.73% -9.21% -2.1%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric bcd6dc3 trunk % Change
serverResponse 324.34 ms +2.32% -6.11% 294.57 ms +8.46% -3.63% 10.11%
firstPaint 373.48 ms +2.34% -2.34% 338.14 ms +12.25% -11.7% 10.45%
domContentLoaded 673.96 ms +4.77% -1.33% 661.95 ms +2.78% -1.41% 1.81%
loaded 674.78 ms +4.76% -1.34% 662.78 ms +2.77% -1.4% 1.81%
firstContentfulPaint 379.71 ms +6.36% -3.61% 378.07 ms +1.52% -3.96% 0.43%
firstBlock 2094.04 ms +1.73% -2.02% 2037.6 ms +0.94% -0.83% 2.77%
type 16.03 ms +8.11% -5.24% 14.77 ms +6.64% -11.31% 8.53%
navigate 108.11 ms +12.03% -12.15% 97.58 ms +0.51% -9.66% 10.79%
loadPatterns 1328.64 ms +4.95% -4.35% 1193.78 ms +8.57% -2.18% 11.3%
loadPages 1028.24 ms +1.21% -1.88% 1004.82 ms +2.46% -2.23% 2.33%
wpTotal 315.94 ms +2.36% -6.26% 286.21 ms +8.72% -3.72% 10.39%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

65038f7 Run

@ramonjd ramonjd self-assigned this Dec 3, 2026
@ramonjd
ramonjd requested review from andrewserong and a balanced review from Copilot December 3, 2026 04:22

Copilot AI 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.

🟢 Approval recommended

No actionable issues were found in the reviewed changes.

No open issues 🎉

What changed in this PR

Media editor panels now throw on duplicate names, allowing existing plugin error handling to remove the conflicting plugin while preserving the original panel.

Changes:

  • Replace silent duplicate handling with an error and simplify registration state.
  • Add coverage for duplicate rejection, plugin error notices, and name reuse after unmounting.
File Description
packages/​media-editor/​src/​components/​media-editor/​test/​panels.browser.test.tsx Tests conflicting-plugin removal and its error notice.
packages/​media-editor/​src/​components/​media-editor/​index.tsx Adds a comment explaining core-panel mount ordering.
packages/​media-editor/​src/​components/​media-editor-panel/​test/​index.jsdom.test.tsx Tests duplicate rejection and same-render name reuse.
packages/​media-editor/​src/​components/​media-editor-panel/​index.tsx Throws on collisions and removes ownership-tracking state.

Review effort: Balanced

@andrewserong andrewserong 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.

Thanks for the tidy-up! Smoke-testing well in both the media modal and media route 👍

@ramonjd

ramonjd commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Appreciate the quick review!

@ramonjd
ramonjd merged commit 707d1fe into trunk Dec 3, 2026
116 of 117 checks passed
@ramonjd
ramonjd deleted the update/media-editor-panel-duplicate-name-error branch December 3, 2026 06:02
@github-actions github-actions Bot added this to the Gutenberg 24.7 milestone Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Media Anything that impacts the experience of managing media [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants