Block Editor: Locate widget form inside post-editor iframe + clone iris/color-picker deps#2306
Closed
Block Editor: Locate widget form inside post-editor iframe + clone iris/color-picker deps#2306
Conversation
22 tasks
Member
Author
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.
Summary
<iframe name="editor-canvas">, butsowbGetBlockForm()only knew about the Site Editor canvas selector. Form lookup returned empty,$mainForm.sowSetupForm()was never called, and no click handlers were ever bound.#jquery-touch-punch-js,#iris-js, and#wp-color-picker-jsto the iframe-clone allowlist so the asset chain is complete. Verified via in-page diagnostic that these were already present via WP's bridge — but having them in the explicit allowlist closes a real gap and is the same shape as existing entries.Root cause (verified with runtime diagnostic, not guessed)
Inline debug emitted into both contexts on WP 6.9.4 confirmed:
name=editor-canvas):[data-block]and.siteorigin-widget-form-mainexist;data(sow-form-setup)=undefined; all jQuery / jQuery UI / wp-color-picker globals already present.[data-block]count is 0 — block tree lives only in the iframe.sowbGetBlockForm()queried the parent doc, found nothing, and the form-init bailed out.The fix re-resolves the editor canvas on every call (Site Editor selector → post editor iframe selector → parent-doc fallback) and uses
.contents()to descend into whichever iframe is mounted. Caching is preserved but only written when the canvas is actually present, so we never lock in an empty result before the iframe mounts.Test plan
widgets.phpBlock Widgets screen (no iframe): widget forms still open and behave (parent-doc fallback branch).[data-block]or jQuery scope.