Skip to content

Fix: media popup in elementor - #2046

Merged
KMchaudhary merged 2 commits into
developfrom
fix/media-popup-elementor
Jul 28, 2026
Merged

Fix: media popup in elementor#2046
KMchaudhary merged 2 commits into
developfrom
fix/media-popup-elementor

Conversation

@rudrakshi-gupta

Copy link
Copy Markdown
Member

Before

Screenshot 2026-07-27 at 8 07 43 PM

After

Screenshot 2026-07-27 at 8 07 53 PM Screenshot 2026-07-27 at 8 09 20 PM

@rudrakshi-gupta rudrakshi-gupta self-assigned this Jul 27, 2026
Copilot AI review requested due to automatic review settings July 27, 2026 14:41

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.

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-opened event 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_script dependencies so wp.* externals (notably wp.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.

Comment thread assets/src/js/media-library/index.js Outdated
Comment thread assets/src/js/media-library/index.js Outdated
Comment thread assets/src/js/media-library/index.js Outdated
Comment thread pages/media-library/index.js Outdated
Comment thread inc/classes/class-pages.php Outdated
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
KMchaudhary merged commit 3dd5d9a into develop Jul 28, 2026
2 of 4 checks passed
@KMchaudhary
KMchaudhary deleted the fix/media-popup-elementor branch July 28, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants