Fix: media popup in elementor - #2046
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR fixes the media-library sidebar not mounting reliably inside the Elementor media popup by rendering into the exact frame/menu root and by ensuring all required WordPress package globals are enqueued.
Changes:
- Pass the exact sidebar root element via a
media-frame-openedevent payload and render React into that node (avoids “last visible container” race). - Add an Elementor-specific retry loop to mount the sidebar once the frame menu exists.
- Expand
wp_register_scriptdependencies sowp.*externals (notablywp.primitives) are available in non-block-editor contexts.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| pages/media-library/index.js | Adds renderSidebarInto() helper and supports event-passed root mounting for the React sidebar. |
| inc/classes/class-pages.php | Declares additional wp-* script dependencies so externals exist in Elementor/editor contexts. |
| assets/src/js/media-library/index.js | Changes sidebar injection logic: target current frame, retry until menu exists, and pass root element through a custom event. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Resolve PR review feedback for media popup sidebar mount - Use firstElementChild to avoid HierarchyRequestError on text nodes - Extract shared sidebar-mount helper with named retry constants - Track React root via data attr flag instead of React internals - Filter wp-* script deps to registered handles before enqueue
KMchaudhary
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before
After