Repository navigation
Media editor: Throw when a panel takes a name already in use - #87792
Conversation
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.
🤖 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: -78 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
|
There was a problem hiding this comment.
🟢 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
left a comment
There was a problem hiding this comment.
Thanks for the tidy-up! Smoke-testing well in both the media modal and media route 👍
|
Appreciate the quick review! |
What?
Follow-up to #84664.
A media editor panel that takes a name already used by a mounted panel now throws an error.
PluginAreacatches 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.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.