Skip to content

Probe the editor canvas iframe for block colors - #8179

Merged
donnapep merged 5 commits into
trunkfrom
block-color-probe-iframe
Aug 18, 2026
Merged

donnapep merged 5 commits into
trunkfrom
block-color-probe-iframe

Conversation

@donnapep

@donnapep donnapep commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

Resolves SEN-141.

Proposed Changes

Course and lesson blocks (Course Outline modules, Course Progress, Course
Results) pick their default colors from the active theme by reading the
computed styles of a hidden probe element. The post editor now renders inside
an iframe, so the theme's styles live only inside that iframe's document. The
probe was still added to the outer document, where those styles don't exist, so
it read empty values — blocks lost their theme color defaults and fell back to a
different color.

This resolves the probe against the editor-canvas iframe document when present,
falls back to the outer document when it isn't (non-iframed editors), and reads
computed styles from that document's own window.

Screenshots

Before After
Screenshot 2026-08-18 at 10 17 16 AM Screenshot 2026-08-18 at 10 16 40 AM

Testing Instructions

  • Activate a block theme with a vivid primary color (e.g. Twenty Twenty-Three, primary = lime green).
  • Create a new course and add a Course Outline block with a Module.
  • Confirm the module header renders in the theme's primary color (lime), not gray.
  • Save, then reopen — the header keeps the theme color.
  • Add a Course List block and confirm the Course Progress bar inside it defaults to the theme color.
  • Add a Course Results block to a page and confirm its section headers default to the theme color.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch - Backward-compatible bug fixes

Type

  • Fixed - Fixes a bug

Message

Fixed course and lesson block colors not matching the theme in the iframed post editor.

The color probe read the theme's button colors from the outer document.
The post editor now renders inside an iframe, so those styles live only
in the canvas document and the probe returned empty values, leaving
course/lesson blocks without their theme color defaults.

Probe the editor-canvas iframe document when present, falling back to
the outer document otherwise, and read computed styles from that
document's own window.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 18, 2026 13:33
@donnapep donnapep added this to the 4.26.3 milestone Aug 18, 2026
@github-actions

github-actions Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

WordPress Playground Preview

The changes in this pull request can previewed and tested using a WordPress Playground instance.

Open WordPress Playground Preview

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

This PR fixes block default color probing in WordPress’ iframed post editor by resolving the hidden “probe” element against the editor-canvas iframe document (where the active theme styles actually live), while still supporting non-iframed editor contexts.

Changes:

  • Detect the editor-canvas iframe and probe styles within its contentDocument (fallback to the outer document when not present).
  • Read computed styles using the probed document’s own defaultView (instead of the outer window).
  • Add a unit test covering the iframed-editor probing behavior, plus a changelog entry.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
assets/react-hooks/probe-styles.js Probes block colors against the editor-canvas iframe document (when present) and uses that document’s window for computed styles.
assets/react-hooks/probe-styles.test.js Adds coverage to ensure probing prefers the iframe’s styles and resets memoization between tests.
changelog/block-color-probe-iframe Records the user-facing fix in the changelog.
Suppressed comments (1)

assets/react-hooks/probe-styles.js:107

  • To make the memoization safe now that getProbeStyles depends on probeDocument, add a resolver so lodash keys the cache by the probed document (instead of the implicit undefined key).
} );

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread assets/react-hooks/probe-styles.js Outdated
Comment thread assets/react-hooks/probe-styles.js Outdated
donnapep and others added 2 commits August 18, 2026 09:49
Key the probe cache by the probed document so a call made before the
editor canvas iframe mounts does not cache the outer document's values
for the iframed document. Fall back to the outer window when the probed
document has no defaultView.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@donnapep
donnapep merged commit d100842 into trunk Aug 18, 2026
23 checks passed
@donnapep
donnapep deleted the block-color-probe-iframe branch August 18, 2026 14:18
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