Skip to content

Fixed rendering of block charts inside editor iframe - #1417

Open
girishpanchal30 wants to merge 2 commits into
developmentfrom
bugfix/1413
Open

girishpanchal30 wants to merge 2 commits into
developmentfrom
bugfix/1413

Conversation

@girishpanchal30

Copy link
Copy Markdown
Contributor

Summary

Improved chart rendering in alternative DOM contexts, including iframed block editor canvases, by ensuring D3 and Google Charts resolve containers from the correct document. Refactored DOM access to use React refs, scoped event and message handling to the appropriate window, and introduced a dedicated Google Charts wrapper to ensure reliable container resolution.

Will affect visual aspect of the product

NO

Check before Pull Request is ready:

Closes #1413

@pirate-bot

pirate-bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Plugin build for 127676b is ready 🛎️!

@pirate-bot pirate-bot 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.

🟡 Changes requested

Charts now draw in the iframed editor, but table charts there lose DataTables Responsive, so fix the extension start-up before merge.

Validation details
  • Files reviewed: 8/8 changed files. One history question stayed open: code that assumes one editor document and one mounted ref, as in the widgets screen and Customizer.
  • WordPress 7.1.5 sandbox, HEAD build: the Google chart editor test passes at HEAD [R14] and fails at pr-base [R17].
  • The DataTable editor test passes at HEAD [R15].
  • A probe shows Responsive missing in the editor canvas and present on the front end [R35].
  • The new Jest file passes at HEAD [R4]. Against pr-base, one case fails and one passes [R5].
  • Security pass on the changed hunks found no issue.
Untested areas
  • The DataTable editor test at pr-base was inconclusive. A setup break stopped it before the canvas step [R18].
  • Widgets screen and Customizer hosts (one editor document and one mounted ref) were not run.
  • Chart redraw after a canvas-only resize, such as device preview, was not run.
  • FixedHeader in the canvas was checked from source only.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • classes/Visualizer/Gutenberg/src/Components/GoogleChart.js:30-40 — unverified: The wrapper supplies a DOM reference, but whether every draw, lookup and measurement honors it belongs to C7’s react-google-charts 3.0.15 dependency check; handed off without resea…
    • classes/Visualizer/Gutenberg/src/Editor.js:152-163 — unverified: Media callbacks target the outer window. WordPress 5.2 and 7.1 mount media modals in the outer body (/deps/wordpress/5.2/wp-includes/js/media-views.js:4319-4351; /deps/wordpress/7.…
    • Components/ChartSelect.js:178-195 — unverified: Media callbacks target the outer window. WordPress 5.2 and 7.1 mount media modals in the outer body (/deps/wordpress/5.2/wp-includes/js/media-views.js:4319-4351; /deps/wordpress/7.…
    • classes/Visualizer/Gutenberg/src/Components/ChartSelect.js:178-195 — unverified: Same modal placement evidence at WordPress 5.2 and 7.1; classes/Visualizer/Render/Page/Send.php:46-48 calls the popup’s parent callback. Other supported versions remain unchecked.
    • node_modules/react-google-charts/dist/index.esm.js:395-410 — unverified: Version 3.0.15 subscribes redraw exclusively to the outer window.resize. An iframe-only viewport resize misses that subscription. Whether an ordinary editor canvas resize leaves a …
    • js/elementor-widget-preview.js:155-179 — unverified: Observation and initial scanning use the global document, while the Elementor hook accepts an externally supplied scope. Whether that scope can belong to another document depends o…

🤖 Automated review · run code-review-agent_6b055f9cc5dda8.12256733.


🤖 Review agent — review posted ✅ on 1b8813b5 · changes requested · 2 findings · 28 min

Run code-review-agent_6b055f9cc5dda8.12256733 · trail

@pirate-bot pirate-bot 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.

🟢 Approved

The PR passes: DataTables Responsive now starts in the iframed editor, and the redundant Jest case is gone.

Validation details
  • Files reviewed: 8/8 changed files.
  • WordPress 7.1 sandbox, HEAD build: the DataTable editor test gives cd /repo && set -o pipefail; WP_ENV_TESTS_PORT=8080 WP_USERNAME=admin WP_PASSWORD=admin WP_ARTIFACTS_PATH=/workspace/che… printed 1 passed (run R5).
  • With the earlier DataTable.js, the same test gives cp -a /workspace/checks/C1/copy/classes/Visualizer/Gutenberg/build/. /repo/classes/Visualizer/Gutenberg/build/ && cmp /r… printed 1 failed (run R7) on td.dtr-control.
  • Canvas probe at 420px: cd /workspace; wp post meta update 27 visualizer-chart-library DataTable 2>&1|tail -1; wp post meta update 28 visualizer… printed "tableClass":"dataTable dtr-inline collapsed" (run R14). The earlier DataTable.js gives cp -a /workspace/checks/C1/copy/classes/Visualizer/Gutenberg/build/. /repo/classes/Visualizer/Gutenberg/build/ && cd /wo… printed "settingsResponsive":"undefined" (run R15).
  • Responsive 3.0.8 source: a start after init still sizes columns. The front end skips a second start.
  • Security pass on the changed hunks found no issue.
Untested areas
  • Keyboard Enter on a collapsed row and keyboard paging in the canvas were not settled. The editor took focus from the table.
  • Freeze Header does not apply in the canvas. The library cannot target the iframe.
  • The front-end table did not render in this sandbox. The diff does not change the front-end renderer.
  • Device preview, media callbacks on other WordPress versions, Elementor, widgets and Customizer were not run.
  • The variant pass did not settle these places, where the fixed cause may still reach:
    • node_modules/react-google-charts/dist/index.esm.js:395-410 — unverified: react-google-charts 3.0.15 redraws through outer window.addEventListener("resize", this.onResize). Still missing: a source-supported editor action that changes only the iframe view…
    • classes/Visualizer/Gutenberg/src/Components/ChartSelect.js:178-195 — unverified: outer send_to_editor matches outer-mounted media modals in WordPress 5.2 and 7.1 (/deps/wordpress/5.2/wp-includes/js/media-views.js:4319-4351; /deps/wordpress/7.1/wp-includes/js/me…
    • classes/Visualizer/Gutenberg/src/Editor.js:152-163 — unverified: the same modal-location evidence applies; js/preview.js:137-141 posts the chart ID to its parent. The complete media-iframe nesting across other supported WordPress versions remain…
    • js/elementor-widget-preview.js:155-179 — unverified: prior ruling retained: document observation and window event subscription remain outer-global; the installed Elementor version and its script/document placement were not establishe…
    • js/lib/datatables.min.js:16 — unverified: without ResizeObserver, resizing falls back to H(W).on("resize.DT-"+t.sInstance,D), using the outer window. Missing fact: whether a supported browser reaches this fallback.
    • not reached: bulk bundled-library AST output, including js/lib/chartjs.min.js, truncated during the initial search

🤖 Automated review · run code-review-agent_6b056a54c573b5.39898505.


🤖 Review agent — review posted ✅ on 127676be · approved · 0 findings · 28 min

Run code-review-agent_6b056a54c573b5.39898505 · trail

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.

2 participants